@@ -132,8 +132,7 @@ private async void ChangedAsync(object sender, FileSystemEventArgs e)
132
132
133
133
// This check is only required because we can not prevent circular calls because of the simplicity of this example.
134
134
// In your real-life application you will not send updates from server back to client that issued the update.
135
- if ( FsPath . Exists ( userFileSystemPath )
136
- && IsModified ( userFileSystemPath , remoteStoragePath ) )
135
+ if ( IsModified ( userFileSystemPath , remoteStoragePath ) )
137
136
{
138
137
FileSystemInfo remoteStorageItem = FsPath . GetFileSystemItem ( remoteStoragePath ) ;
139
138
if ( remoteStorageItem != null )
@@ -226,26 +225,26 @@ public void Dispose()
226
225
/// <returns>True if file is modified. False - otherwise.</returns>
227
226
internal static bool IsModified ( string userFileSystemPath , string remoteStoragePath )
228
227
{
229
- if ( FsPath . IsFolder ( userFileSystemPath ) && FsPath . IsFolder ( remoteStoragePath ) )
230
- {
231
- return false ;
232
- }
233
-
234
- FileInfo fiUserFileSystem = new FileInfo ( userFileSystemPath ) ;
235
- FileInfo fiRemoteStorage = new FileInfo ( remoteStoragePath ) ;
236
-
237
- // This check is to prevent circular calls. In you real app you wouuld not send notifications to the client that generated the event.
238
- if ( fiUserFileSystem . LastWriteTimeUtc >= fiRemoteStorage . LastWriteTimeUtc )
228
+ if ( ! FsPath . TryIsFolder ( userFileSystemPath , out bool isFolder1 ) || isFolder1 || ! FsPath . TryIsFolder ( remoteStoragePath , out bool isFolder2 ) || isFolder2 )
239
229
{
240
230
return false ;
241
231
}
242
232
243
233
try
244
234
{
235
+ FileInfo fiUserFileSystem = new FileInfo ( userFileSystemPath ) ;
236
+ FileInfo fiRemoteStorage = new FileInfo ( remoteStoragePath ) ;
237
+
238
+ // This check is to prevent circular calls. In your real app you would not send notifications to the client that generated the event.
239
+ if ( fiUserFileSystem . LastWriteTimeUtc >= fiRemoteStorage . LastWriteTimeUtc )
240
+ {
241
+ return false ;
242
+ }
243
+
245
244
if ( fiUserFileSystem . Length == fiRemoteStorage . Length )
246
245
{
247
246
// Verify that the file is not offline,
248
- // therwise the file will be hydrated when the file stream is opened.
247
+ // otherwise the file will be hydrated when the file stream is opened.
249
248
if ( fiUserFileSystem . Attributes . HasFlag ( System . IO . FileAttributes . Offline )
250
249
|| fiUserFileSystem . Attributes . HasFlag ( System . IO . FileAttributes . Offline ) )
251
250
{
0 commit comments