.docxファイルFileSystemWatcher
の検出に使用しています。ファイルは開いているときに検出されますが、ファイル名は常に「破損」しています。
3つの例:
私のファイル名が:2711111.docxの場合、受信したファイル名
FileSystemWatcher.Changed
は:〜$711111.docxです。ファイルの場合:* 2711111_1.docx *ファイル名を取得します:*〜$ 11111_1.docx *ファイル名がどうなるかわからないので、一般的な解決策を探しています。
ファイルに文字が含まれている/文字で始まっている場合、それは発生しません。
これが私のコードです
MyPath = String.Format(@"C:\Users\{0}\NRPortbl\ACTIVE\{1}\"",
Public.UserName, Public.UserName);
FileSystemWatcher watcher = new FileSystemWatcher();
if (!System.IO.Directory.Exists(MyPath))
{
Public.Logger.Error(
String.Format
("Path of folders {0} not found", MyPath));
System.Windows.Forms.MessageBox.Show(
String.Format(
"There was a problem loading {0} " +
"NRPortbl libraray, contact administrator", Public.UserName));
return;
}
watcher.Path = MyPath;
watcher.Filter = "*.Docx";
watcher.IncludeSubdirectories = false;
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnDeleted);
watcher.EnableRaisingEvents = true; ...
public void OnChanged(object source, FileSystemEventArgs e) {...}
ヘルプは大歓迎です:)ありがとう!