jamppi
asked on
Click-Once deployment and System.Io.File.Exists Fails after install
Hi!
could somebody tell me why this works fine when debugging but fails after i install the Click-once application. i don't get any error messages and the application keeps
running but all file.exists calls just doesn't work. Trust issue ? (visual studio 2008)
if File.Exists("C:\Documents and Settings\All Users\Documents\images\tes timage.jpg ") Then
......
could somebody tell me why this works fine when debugging but fails after i install the Click-once application. i don't get any error messages and the application keeps
running but all file.exists calls just doesn't work. Trust issue ? (visual studio 2008)
if File.Exists("C:\Documents and Settings\All Users\Documents\images\tes
......
what error do you get?
ASKER
I dont get any errors, the code is not executed. but other parts of the solution runs fine.
Try using the standard folder path for MyDocumets e.g
Dim ThePath = Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "images\testimage.jpg")
If File.Exists(ThePath) Then
'do yo thang!
End If
nepaluz gave what could be the right solution, but did not say why you should use that technique.
Many standard directories are not so standard. They change name between operating systems and/or operating system languages. Documents and Settings has been replaced by Users in Windows Vista. It is called Utilisateurs on a French installation of Windows.
The technique given by nepaluz simply retrieve the name of the directory as it exists on the computer on which the code is running. You should always use that technique when you reference one of the standard directories, such as My Documents, My Music, Windows, System, etc.
Many standard directories are not so standard. They change name between operating systems and/or operating system languages. Documents and Settings has been replaced by Users in Windows Vista. It is called Utilisateurs on a French installation of Windows.
The technique given by nepaluz simply retrieve the name of the directory as it exists on the computer on which the code is running. You should always use that technique when you reference one of the standard directories, such as My Documents, My Music, Windows, System, etc.
ASKER
Hi!
I will test that!
But it doesn't answer why it works when i debug but not when i deploy it!
I will test that!
But it doesn't answer why it works when i debug but not when i deploy it!
File.Exists() returns a Boolean (True or False), so the patently obvious reason is that it has returned a False (and that the file does not exist!).
However, since it does return a true while in debug mode suggests that the file actually exists, and you are right to assume it should return a true after compilation.
I suggested you use the standard naming used by the framework to help narrow down the cause of this anomally. What is clear is that at runtime outside the debuger it returns a false, so it is over to you!
However, since it does return a true while in debug mode suggests that the file actually exists, and you are right to assume it should return a true after compilation.
I suggested you use the standard naming used by the framework to help narrow down the cause of this anomally. What is clear is that at runtime outside the debuger it returns a false, so it is over to you!
ASKER
Hi!
I'm still having the same issue.
Btw. My.Computer.FileSystem.Spe cialDirect ories.MyDo cuments gives the path to \userxxxxx\Mydocuments.
i need to get to 'All Users\Documents' (XP) or ' C:\Users\Public\Documents\ ' (win7)
I'm still having the same issue.
Btw. My.Computer.FileSystem.Spe
i need to get to 'All Users\Documents' (XP) or ' C:\Users\Public\Documents\
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.