在USB驱动器上构建项目时出现损坏 [英] Corruption when building projects on a USB drive

查看:58
本文介绍了在USB驱动器上构建项目时出现损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git服务器上有很多项目,我可以在许多PC上下载,构建和运行而不会出现问题。但是,如果我将其中一个项目下载或复制到USB驱动器,它将编译但在运行时会生成异常。有时它会立即崩溃,
有时项目会运行一段时间然后崩溃。另外,VS总是想重建项目。

I have a number of projects on a git server that I can download, build and run without issue on a number of PCs. However if I download or copy one of these projects to a USB drive, it will compile but generates exceptions when run. Sometimes it crashes immediately, sometimes projects will run for a while and then crash. Additionally, VS always wants to rebuild the project.

我不相信USB驱动器有问题。将源下载到C驱动器和USB驱动器后,WinMerge报告所有文件都相同。在我测试过的所有USB驱动器上都会出现同样的问题,使用内置驱动器时也不会发生。
项目在驱动器上的位置也没有效果。

I don't believe the USB drives are at fault here. After downloading the source to the C drive and a USB drive, WinMerge reports all the files are identical. The same issue occurs on all USB drives I have tested and never occurs when using internal drives. The location of the project on the drive also has no effect.

任何人都有任何想法如何从USB驱动器构建项目?我在Windows 10上使用MSVC 2015。

Anyone have any ideas how to get projects to build from a USB drive? I'm using MSVC 2015 on Windows 10.




这可能不相关但我知道有Windows中长期存在的"功能",写入USB驱动器时会导致文件损坏。它似乎只影响以32位模式构建的程序并在64位系统上运行。例如。请参阅下面的代码。

This may not be relevant but I know there is a long-standing 'feature' in windows which will cause file corruption when writing to USB drives. It appears only to affect programs built in 32-bit mode and run on a 64-bit system. E.g. see the code below.

#include <fstream>
using namespace std;
int main()
{
  {
    ofstream out ("test.txt", ios::out | ios::binary);
    out << "1234567890" << '\n';
  }
  {
    ofstream out ("test.txt", ios::out | ios::binary);
    out << "abcdef" << '\n';
  }
  return 0;
}

在内部驱动器上,生成的文本文件包含:

On an internal drive, the resulting text file contains:

abcdef

但在USB驱动器上运行时,它包含:

but when run on a USB drive it contains:

推荐答案

在内部驱动器上,生成的文本文件包含:abcdef,但在USB驱动器上运行时,它包含:abcdef 890
On an internal drive, the resulting text file contains: abcdef but when run on a USB drive it contains: abcdef 890

抱歉,我无法用Win10 15063.540和格式化为NTFS的USB 2.0驱动器重复此操作。该文件包含"abcdef"。

Sorry but I could not repro this with Win10 15063.540 and USB 2.0 drive formatted as NTFS. The file contains "abcdef".

你的是什么:flash还是HD? FAT32?

What is yours: flash or HD? FAT32?

- pa


这篇关于在USB驱动器上构建项目时出现损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆