|
-
Jul 20th, 2010, 02:03 PM
#1
Thread Starter
Junior Member
Strange file not found error
I have a program that looks for a file named 'license.dat' upon startup. The program first checks the directory it's in, and if the license file isn't there, it prompts the user to select the license file with a file browser dialog. I have tested this code and confirmed it working in a number of different OS environments.
Recently, I received reports from two users (one in Germany and one in Italy) that the program can't find the license on their computers, even though it is present in the program's directory and they manually selected it with the file browser dialog. The only commonality I'm seeing here is a lack of English OS, but beyond that I'm stumped.
Any ideas what could be causing this?
This is the code I'm using:
Code:
If System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "license.dat") = False Then
File dialog code goes here
-
Jul 20th, 2010, 02:07 PM
#2
Hyperactive Member
Re: Strange file not found error
What OS are you running?
Open the Language Bar and set it from English to German and then retest on your system.
-
Jul 20th, 2010, 02:07 PM
#3
Re: Strange file not found error
Are you able to test it in a non English environment? I can't imagine that's the issue since you're not hard coding the path check, but it's work looking into.
Could it be a permissions issue?
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Jul 20th, 2010, 04:16 PM
#4
Thread Starter
Junior Member
Re: Strange file not found error
I switched my computer over to German regional settings and found that the program would still launch if the license file and the program were in the same directory. I was, however, able to reproduce the error when the license file was not present in the same directory and I was prompted to select it.
I'm really not sure what could be causing this. Here's the code I'm using, which works in English environments:
Code:
If System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "license.dat") = False Then
MsgBox("License not found. Please select your license file.")
Dim fdlg As OpenFileDialog = New OpenFileDialog()
fdlg.Title = "Please select your license."
fdlg.InitialDirectory = "c:\"
fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fdlg.FilterIndex = 2
fdlg.RestoreDirectory = True
If fdlg.ShowDialog() = DialogResult.OK Then
Try
Dim licensedate As String = System.IO.File.ReadAllText(fdlg.FileName)
Unrelated code continues...
-
Jul 20th, 2010, 04:19 PM
#5
Thread Starter
Junior Member
Re: Strange file not found error
This is the error one of my users reported:
Code:
System.IO.FileNotFoundException: Could not find file 'C:\Users\ak24\Desktop\license.dat'.
File name: 'C:\Users\ak24\Desktop\license.dat'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at ChatSniper.MainForm.MainForm_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
-
Jul 20th, 2010, 07:38 PM
#6
Re: Strange file not found error
Where did they have the program located? On the desktop? And can they confirm that the license.dat file was there?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|