Eric, Are you sure that the file is finished being copied before you start to use it? I wrote a pretty extensive system based on the file system watcher and ran into that issue. I ended up changing extensions to .working until I was done copying the file. That way if my mask was StockInfo_*.dat I wouldn't even see the TEMP_StockInfo_*.working and simply renamed it when finished. Just a thought.
Travis D. Falls | Consultant RAFT.Net IT | 860.547.4070 | [EMAIL PROTECTED] -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of e_throckmorton Sent: Monday, December 12, 2005 1:43 PM To: [email protected] Subject: [AspNetAnyQuestionIsOk] Re: File System watcher I tried that code and got the following error: System.UnauthorizedAccessException: Access to the path is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.__Error.WinIOError() at System.IO.FileInfo.MoveTo(String destFileName) at readtextfile.WebForm1.MoveFile(String slocFile, String sdesFile) in c:\inetpub\wwwroot\readtextfile\WebForm1.aspx.vb:line 170 Any ideas why? Thanks, Eric --- In [email protected], shannon hall <[EMAIL PROTECTED]> wrote: > > > Private Sub MoveFile(ByVal slocFile As String, > ByVal sdesFile As String) > Try > ' Create a reference to a file, which > might or might not exist. > ' If it does not exist, it is not yet > created. > Dim fi As New FileInfo(slocFile) > ' Create a writer, ready to add > entries to the file. > > If File.Exists(sdesFile) Then > ' Ensure that the target file does > not exist, since this is disallowed. > File.Delete(sdesFile) > fi.MoveTo(sdesFile) > Else > ' Move this file to another file. > fi.MoveTo(sdesFile) > End If > > File.Delete(slocFile) > fi = Nothing > Catch ex As Exception > SendErrorMail(ex.Message) > End Try > > > End Sub > --- Eric Throckmorton <[EMAIL PROTECTED]> > wrote: > > > Hello, > > I have a file system watcher looking for a > > creation of new files then running some code to use > > that file, then deleteing it. > > The first thing I do is copy the file to another > > location using the File.copy method but the entire > > file does not copy to the second location. What Am > > I doing wrong here? > > > > Private Sub objWatcher_FileCreated(ByVal > > FullPath As String) Handles objWatcher.FileCreated > > TextBox1.Text &= "File Created: " & FullPath & > > vbCrLf > > path = "C:\Documents and Settings\Eric\Local > > Settings\Application > > > Data\Identities\{CD27FCB2-9E3C-45F7-BC37-93C84C481291} \Microsoft\Outlook > > Express\Inbox.dbx" > > path2 = "C:\Documents and Settings\Eric\My > > Documents\Test\filecopy.txt" > > Try > > ' Ensure that the target does not exist. > > File.Delete(path2) > > ' Copy the file. > > File.Copy(path, path2) > > Console.WriteLine("{0} copied to {1}", path, > > path2) > > ' Try to copy the same file again, which should > > fail. > > File.Copy(path, path2) > > Console.WriteLine("The second Copy operation > > succeeded, which was not expected.") > > Catch exp As Exception > > Console.WriteLine("The second Copy operation > > failed, as expected.") > > End Try > > 'gatherdata1() > > End Sub > > > > > > Thank-you, > > > > Eric > > > > > > > > --------------------------------- > > Yahoo! Shopping > > Find Great Deals on Holiday Gifts at Yahoo! > > Shopping > > > > [Non-text portions of this message have been > > removed] > > > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > Yahoo! Groups Links ************************************************************************* This communication, including attachments, is for the exclusive use of addressee and may contain proprietary, confidential and/or privileged information. If you are not the intended recipient, any use, copying, disclosure, dissemination or distribution is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this communication and destroy all copies. ************************************************************************* ------------------------ Yahoo! Groups Sponsor --------------------~--> Most low income households are not online. Help bridge the digital divide today! http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
