Results 1 to 2 of 2

Thread: Moving a file

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2011
    Posts
    62

    Angry Moving a file

    Hi, so I want to move CH1.bat to C:\Windows. I don't want to specify the path of CH1.bat, so I used this code:

    Code:
     System.IO.File.Move(Application.StartupPath & "\CH1.bat", "C:\Windows\CH1")
    But ALWAYS get
    "Unhandled exeption... blah, blah, blah

    Could not find file

    Details:
    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.IO.FileNotFoundException: Could not find file 'C:\Users\Loren\Desktop\Tests\CH1.bat'.
    File name: 'C:\Users\Loren\Desktop\Tests\CH1.bat'
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
    at System.IO.File.Move(String sourceFileName, String destFileName)
    at UPK.Form1.Button6_Click(Object sender, EventArgs e)
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.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)"

    I thought that code seemed perfect!!?! What's wrong with it! CH1.bat is in the SAME directory as my .exe!
    Last edited by iamanoob; Jun 13th, 2011 at 12:37 AM.

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