Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
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.
Posted
Updated 21-Jun-12 8:25am
v3
Comments
[no name] 21-Jun-12 14:15pm    
Help with what? You did not bother asking a question or defining what you need help with!
Steve Maier 21-Jun-12 14:23pm    
So your installer has to just be with VS2010? Can't you use WiX, InnoSetup, or NSIS? All of those are free.

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.

C#
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);
  }
 }
}
 
Share this answer
 
v2
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900