CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Moving files

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    Moving files

    Hi, since I got my previous problem sorted out real easy by posting on this forum, I decided to post another problem I have. In my code I want to move a file from a path in a text box to another path in a different textbox. For example, say I have C:\Pictures\Flowers.jpg in the first textbox and C:\Programs\ in the other textbox and I click a button, the flowers.jpg in the pictures folder should be moved to the programs folder. Simple enough right? Well how can I do this without it renaming Flowers.jpg to something in the second textbox? Sorry my problem may be confusing.

  2. #2
    Join Date
    Apr 2006
    Posts
    220

    Re: Moving files

    Copy the original file from start location (textbox1 path) to end location (textbox2 path) and then delete the original file. before copy always check if the file exists on the start location otherwise an exception will be thrown.

    clear enough or not ?

  3. #3
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: Moving files

    or check the directory names in the textboxes, if they are the same don't do anything otherwise move the file. you may use System.IO.Path to manipulate path names, and then use System.IO.File to move files.
    Busy

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    210

    Re: Moving files


  5. #5
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    210

    Re: Moving files


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

Featured