使用vs2010为C#应用程序创建安装

编程入门 行业动态 更新时间:2024-10-11 17:25:11
本文介绍了使用vs2010为C#应用程序创建安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对于使用SQL EXpress mdfs的某些c#应用程序,我需要帮助使用vs2010创建安装(最好是创建MSI).我已经尝试了一次单击,但是这不能满足我的需要.我需要安装的SQL Express mdfs必须放置在"C:\ Program Files \''Company""目录或另一个静态目录中,因此应用可以读取和写入这些mdf.这些应用程序也可以位于该目录中,也可以位于子目录中.我有多个共享相同mdfs的小型应用程序,因此应将它们安装在同一目录或子目录中. 如果可用,此安装应在XP,Vista,Win7和Win8中安装相同的文件夹. 我需要使用VS2010 Ultimate中提供的工具来执行此操作.我可以使用任何免费的工具,并且可以获得帮助. 该安装适用于小型办公室中的独立PC. 请帮忙.

I need help to create an install (preferably creating a MSI) using vs2010 for some c# applications that use SQL EXpress mdfs. I have tried the click once, but that does not meet my needs.The SQL Express mdfs that I need installed must be placed in the "C:\Program Files\''Company''" directory, or another static directory, so the apps can read and write to these mdfs. The applications can be there as well, or in a sub-directory. I have multiple small apps that share the same mdfs, so they should be installed either in the same directory or in a sub-directory. This install should install the same folders in XP, Vista, Win7 and Win8 when it is available. I need to do this using the provided tools in VS2010 Ultimate. I can use any tool if it is free and I can get help. The install is for stand alone PCs in small offices. Please help.

推荐答案

我编写了一个具有类似问题的ClickOnce应用程序.我克服了这些问题,甚至想出了一旦为软件付款后如何通过电子邮件发送激活密钥. 通过让您的应用使用Windows注册表,您可以测试一下这是否是首次运行. I wrote a ClickOnce Application with similar problems. I overcame those problems and even figured out how to email an activation key once the software was paid for. By having your App use the windows registry you can test to see if this is the first time the App is being run. void OnFirstRun() { // get directory of datafiles downloaded with the App, this is // an unusual and very long ClickOnce path. String StartupPath = System.Windows.Forms.Application.StartupPath; String OrigMktDataPath = Path.Combine(StartupPath, "MktData"); // get destination path String localAppData = Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData); String DestPath = Path.Combine(localAppData, @"YourCompanyName\YourAppName\"); DirectoryInfo diSource = new DirectoryInfo(OrigMktDataPath); DirectoryInfo diDest = new DirectoryInfo(DestPath); try { if (diSource.Exists) { if (!diDest.Exists) { Directory.CreateDirectory(destPath); } bool OverWrite = false; CopyDir(OrigMktDataPath, DestPath, OverWrite); } } catch (Exception ex) { regWrap.WriteLogException(ex); regWrap.FlushFileStream(); } } private void CopyDir(String PathSrc, String PathDest, bool OverWrite) { DirectoryInfo diSource = new DirectoryInfo(PathSrc); FileInfo[] files = diSource.GetFiles(); String DestFFN; foreach (FileInfo fi in files) { DestFFN = PathDest + fi.Name; if (!File.Exists(DestFFN) || OverWrite) { fi.CopyTo(DestFFN, true); File.SetAttributes(DestFFN, FileAttributes.Normal); } } }

如果ClickOnce不适用于您,并且您想使用Visual Studio 2010,则需要研究安装项目. 此处 [ ^ ]是有关创建一个的MSDN文章. 此处 [ ^ ]是一种Google搜索,可能会有所帮助您会找到更多信息. 使用这些开始您的项目,然后当您遇到更具体的问题时,请回到此处并发布您的问题. 希望这会有所帮助. If ClickOnce will not work for you and you want to use Visual Studio 2010, then you need to research a setup project. Here[^] is an MSDN article about creating one. Here[^] is a google search that may help you find more information. Use these to start working on your project, then when you get stuck with a more specific question come back here and post your question. Hope this helps.

更多推荐

使用vs2010为C#应用程序创建安装

本文发布于:2023-11-12 10:18:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!