Reputation: 1 Apprentice
- Active Members
- Active Posts:
- 81 (0.05 per day)
- 11-April 11
- Profile Views:
- Last Active:
- Feb 25 2015 08:11 PM
- OS Preference:
- Who Cares
- Favorite Browser:
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- Who Cares
- Dream Kudos:
Posts I've Made
Posted 25 Feb 2015Thanks!
Posted 25 Feb 2015The program is not for someone else, it's just for me to send my files to whatever destination i want. It's not big project, just file copy. i have done it many times earlier, since my c++ time. This is the first time i got a bug with it. And i think iterating is the cause for the other thread code's bug. my original intentions was to create this single file copy app, but i diverted to the other program to TEST the folder copying.
If someone can please point out how to add a new item to file R-C menu, i'll manage the code myself. Appreciated.
Posted 25 Feb 2015Thanks for that tlhIn. But my other thread is for a test program -- to copy a directory and all it's files to somewhere else, by extending the folder R-C menu. But i actually need is to copy just one file to another place in hd. Coz, i have these snap files in a folder, and i just need to select only the files i need to copy, not the whole dir. also I think it will be easier than iterating through the dir, finding files and copy each, thus causing my bug in the other thread. The two codes will not conflict. This is for another prog.
Posted 25 Feb 2015??? What class are you using. Both variants FileInfo.CopyTo() take only one path -- the destination.
File.Copy() on the other hand takes two parameters: source and destination. If you are passing the source path for both parameters, then the exception is expected.
Here's a silly question, you may not have a file with a conflicting name at the destination, but do you have a conflicting directory name? Also have you checked to see if you have any hidden or system files in the destination with a conflicting name? (By default Windows Explorer does not show hidden or system files and you'll have to flip a switch to make those visible.)
sorry, i did a mistake in above wordings. yes the copy() takes 1 arg. what i meant was when i create the dest dir path with 'selectedPath' and 'temppath' and pass it to copy(), it restores to the source file gain, not the destination i give it O.o. Really confused about that.
No, i don't think there's a hidden file with that name. The name is just "new text file.txt" -- there's no hidden file with that name is there?. PLUS, the destination folder is empty -- no files to conflict with. and i delete it every time i test the prog. So the program creates the empty folder.
Posted 25 Feb 2015Have you tried checking if it exists programmatically?
If (!File.Exists(tempFile)) File.CopyTo(tempFile);
That way it doesn't try to overwrite and it it won't throw an error if it truly does exist.
If nothing is copied that will prove your source and destination paths are NOT what you think they are.
Yes tlhIn, the problem IS that CopyTo() takes both paths as source paths. Coz the exception says " "\file.txt" already exists". But the variables im using ( tempfile and destination.SelectedPath) are actually getting the correct paths. i donno wts happening!
- Member Title:
- D.I.C Head
- Age Unknown
- Birthday Unknown
KasunL hasn't added any friends yet.