Results 1 to 7 of 7

Thread: [RESOLVED] FileIO.FileSystem.CopyFile not copying entire file???

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Resolved [RESOLVED] FileIO.FileSystem.CopyFile not copying entire file???

    I am using FileIO.FileSystem.CopyFile to copy a file that is ~50 MB ... my issue is that it copys the file without erroring ... but the output filesize is only the first 1.39 MB of the file??? ... has anyone come across this before? ... should I just use other methods to copy the file?

    vb Code:
    1. FileIO.FileSystem.CopyFile(FileIn, FileOut, True)

    Thanks,
    Kris

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: FileIO.FileSystem.CopyFile not copying entire file???

    Not that it should make a difference, but that method is intended to be called as My.Computer.FileSystem.CopyFile.

    Have you tried IO.File.Copy on the same file to see if that works? Have you tried that same CopyFile method on other files in the same and different locations to see if it works on them? Just trying to get a feel for whether this is an isolated issue because I can't think of any reasonable explanation for the behaviour you're seeing.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: FileIO.FileSystem.CopyFile not copying entire file???

    Quote Originally Posted by i00 View Post
    should I just use other methods to copy the file?
    Personally, I tend to use System.IO but there's nothing wrong with using My.Comuter.FileSystem. I would just recommend consistency in whatever option you choose, e.g. if you use File.Copy then use Path.Combine and if you use My.Computer.FileSystem.CopyFile then use My.Computer.FileSystem.CombinePath. I tend to use My only when it provides functionality not provided elsewhere, e.g. the overloads of CopyFile that provide their own progress dialogue.

  4. #4

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: FileIO.FileSystem.CopyFile not copying entire file???

    Thanks, I will try those suggestions later, and there is a reason that I specifically use this method rather than other methods to copy a file...

    it is so that it presents this if the file is in use:
    Name:  Replace.png
Views: 1155
Size:  11.5 KB

    Also it seems to work for ALL other files that I have ever copied using this method ... just this one file that causes issues

    Kris

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: FileIO.FileSystem.CopyFile not copying entire file???

    Quote Originally Posted by i00 View Post
    Thanks, I will try those suggestions later, and there is a reason that I specifically use this method rather than other methods to copy a file...

    it is so that it presents this if the file is in use:
    Name:  Replace.png
Views: 1155
Size:  11.5 KB

    Also it seems to work for ALL other files that I have ever copied using this method ... just this one file that causes issues

    Kris
    Makes sense. I believe that FileSystem uses the same shell functions that Windows/File Explorer uses so you get the same dialogues.

    I can't think of anything that would cause that behaviour, unless there's something about the inner workings of that method that I'm unaware of. What happens if you try to copy that file in Windows/File Explorer? What happens if you use File.Copy?

  6. #6
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: FileIO.FileSystem.CopyFile not copying entire file???

    Quote Originally Posted by i00 View Post
    I am using FileIO.FileSystem.CopyFile to copy a file that is ~50 MB ... my issue is that it copys the file without erroring ... but the output filesize is only the first 1.39 MB of the file??? ... has anyone come across this before? ... should I just use other methods to copy the file?

    vb Code:
    1. FileIO.FileSystem.CopyFile(FileIn, FileOut, True)
    Is your source file on a NTFS partition and the destination on a non-NTFS partition?

    The reason that I ask this is because the only scenario that I can think of that would produce your results is a NTFS source file where the bulk of the data is in alternate data streams and you are copying the file to a non-NTFS destination (FAT formatted thumb drive?). The alternate data streams would not be able to be copied in that case. I just tested this case and no errors are generated. Doing it through File Explorer produces a warning about copying a file without its properties.

  7. #7

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: FileIO.FileSystem.CopyFile not copying entire file???

    Nope ... source and dest were on the same HDD ... NTFS... seemed to do it with that file only, but explorer could copy the file with no probs ... just changed the method used to copy ... and prob solved ... doesn't really matter about loosing the windows dialogs ... just replaced them with mine.

    Kris

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