Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

File.Move copies file instead

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
brian.gabriel@gmail.com - 15 Jul 2005 18:10 GMT
I have a ASP.Net application written in VB.Net, I have a file import
function that imports a file then moves the file to an archive.

The problem is that the File.Move statement copies the file, but
original file is not removed even though the file now shows up in the
archive.

There are no errors being reported, we log errors to the event log via
the exception handling application block.  There are no errors in the
system, app. or security logs.  Everything else happen normally.

Here is the offending snippet:

   Private Sub MoveFiles(ByVal sFrom As String, ByVal sTo As String)
       If File.Exists(sFrom) Then
           File.Move(sFrom, sTo)
       End If
   End Sub

Thanks,

Brian
zdrakec - 15 Jul 2005 19:35 GMT
Well, you could add, after File.Move(sFrom,sTo):

If File.Exists(sTo)  'make sure the file actually got there!
 If File.Exists(sFrom) Then Kill(sFrom)  'if it did move after all,
just killing it will throw an exception
End If

Cheers,
zdrakec

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.