.net - vb.net file watch returns an incorrect filename -
I am trying to use the VB.Net FileSystemWatcher class to view a folder for creating excel files. When a .xls file is created in the folder, I get a response, but there is a problem with the code below:
Private Sub AddWatch () New File System Watch Adapter Watch See as. , Knowofffilechange clock Filter = "*. *" Clock. NotifierFilters = NotifyFilters.LastWrite watch.Path = "C: \ Documents and Settings \ my.user \ Desktop \ testing" watch.EnableRaisingEvents = True End Sub Private Sub FileChange (Byval obj object, system byIV .FileSystemEventArgs) Debug. Print ("Change Type:" & amp; e.ChangeType.ToString & amp; ", Path:" & amp; e.FullPath.ToString) End Sub
I will get a text file back in, I will get the proper file name back ("C: \ Documents and Settings \ my.user \ Desktop \ testing \ foo.txt"). However, when I save an excel file to the folder, the path is still correct, but the filename is garbage (always with the same file name, always 8 characters like "C: \ Documents and Settings \ my. User \ Desktop \ Test \ DE0B5800 ".) This search can not be found on Google or anything here, and as always MSDN is a little help before anyone runs on it or know where I can get more information?
In summary:
when Excel saves a file, Excel performs these steps:
- Excel creates a randomly named temporary file (for example, with no file name extension with Cedd4100 ) In the destination folder that you specified in the Save As dialog box. The entire workbook is written in the temporary file.
- If changes are being saved to an existing file, Excel removes the original file.
- Renames the Excel temporary file The Excel returns the temporary file into the file name that you specified (such as Book1.xls) in the Save As dialog box.
Comments
Post a Comment