diff --git a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder.cpp b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder.cpp index 7d88a48543..8700b048a9 100644 --- a/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder.cpp +++ b/targets/FreeRTOS_ESP32/ESP32_WROOM_32/nanoCLR/Windows.Storage/win_storage_native_Windows_Storage_StorageFolder.cpp @@ -726,10 +726,16 @@ HRESULT Library_win_storage_native_Windows_Storage_StorageFolder::CreateFileNati break; case CreationCollisionOption_OpenIfExists: - // Open existing file & truncate - mode[0] = 'r'; - mode[1] = '+'; - break; + if (fileExists) + { + // Open existing file + mode[0] = 'r'; + } + else + { + NANOCLR_SET_AND_LEAVE(CLR_E_FILE_NOT_FOUND); + } + break; case CreationCollisionOption_GenerateUniqueName: // this operation is not supported in nanoFramework