Link to home
Start Free TrialLog in
Avatar of dyarosh
dyarosh

asked on

Need help with MS VS 2010 Deployment Project

I have a WinForms application created using MS VS 2010.  I created a deployment package but am having a problem accessing a folder in the package.

I have a function to export data.  I want the exported data to be stored in a folder in the user's My Documents folder.  In my deployment package I have added User's Personal Data Folder to the File System in the Deployment package.

User generated image

In my application I do the following to create the file.  I want the file to be created in the User's Personal Data folder.
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string FileName = mydocpath + @"\HWLocal77\Exports\Export_" + curDate.Month.ToString() + curDate.Year.ToString() + ".txt";
            using (StreamWriter sw = new StreamWriter(FileName))
            {
                // my extract code is here
            }

Open in new window


When I run the install, the HWLocal77\Exports is created in my My Documents folder but when I run the application and try and export the data, the application creates the following path:

C:\Users\Owner\Documents\HWLocal77\Exports\Export_72014.txt

and I get an error stating part of the path does not exist.  The folder exists in the My Documents folder.

User generated image
But it doesn't exist in the C:\Users\Owner\Documents folder.

Can someone please help me figure out how to change my Deployment Package or what change I need to make to my program?  Any help is greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dyarosh
dyarosh

ASKER

After looking closer at the error message I realized the folder name was being created as "HWLocal77" but the folder was "HWLocal 77".  Once I fixed that everything worked.  Thank you for your help.