0

I'm creating a small c# winforms application. It uses a sqlite database to store data, I've been asked to add an update feature into this app so users can update the sqlite files, aswell as any other files, without having to re-install the app.

The problem is, when I do an update it looks as though everything has worked, no errors, etc. but when I look in the applications install directory some of the downloaded files are missing (usually pdf files), once an update has downloaded it creates an Updates.txt file to keep track of the updates it's done. If I then uninstall and re-install the app it acts as though its already done an update even though the Updates.txt file is missing.

The weird thing is that if I hit run in Visual Studio and do an update it all works without any problems 100% of the time, Its just when I build the setup project and install that which causes problems. Maybe there's a setting in the setup project which cause files to be copied somewhere else? I have absolutely no idea.

Please help. Thanks.

EDIT: This is how i'm downloading the files

String filename = "//test.pdf";

WebClient client = new WebClient();
client.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);

client.DownloadFileAsync(new Uri(dlFile), System.IO.Directory.GetCurrentDirectory() + filename);

UPDATE: This was a permissions issue, to fix it I forced the app to run as administrator.

Community
  • 1
  • 1
JDx
  • 2,615
  • 3
  • 22
  • 33
  • What is the directory path to the stored files? – Maciej May 25 '12 at 15:09
  • 1
    Do you checked you have right permission on the folder you use? – Ras May 25 '12 at 15:07
  • Hi, I've tried changing the permissions but it doesn't look like its had any affect. Still the same problem. If this would have worked, how would i ensure that the permissions are set correctly on another users machine without having access to it? – JDx May 25 '12 at 15:25
  • 1
    If the computer is on your network, you can go to properties->edit->add->locations, select your network, and find the computer. You might try (temporarily) giving the "Everyone" user (just type "everyone" for the user) full read/write access to the folder. Just make sure that you're in the right location (in your case you'd want to have the network server as the location) – Phillip Schmidt May 25 '12 at 15:39
  • On further investigation it was a permissions issue. Thats great, thanks @PhillipSchmidt! – JDx May 25 '12 at 15:57

2 Answers2

1

If you install application in Program Files, then probably you don't have permission to write files. You need to run application as administrator, or elevate it by code.

cichy
  • 10,464
  • 4
  • 26
  • 36
1

I'd be surprised if it weren't a permissions issue. Give the appropriate user read/write to the folder you're writing to and see if that doesn't fix the issue. The reason it works within visual studio is that visual studio is (more than likely) running as administrator, and thus so are its subtasks, like this one. If this doesn't work, throw in some more debug statements to see where things start going wrong.

Phillip Schmidt
  • 8,805
  • 3
  • 43
  • 67