Results 1 to 6 of 6

Thread: Strange file not found error

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2010
    Posts
    17

    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

  2. #2
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Michigan
    Posts
    304

    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.

  3. #3
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    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

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2010
    Posts
    17

    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...

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2010
    Posts
    17

    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)

  6. #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
  •  



Click Here to Expand Forum to Full Width