문제

Hello is there any windows API function that would return if drive is writable. Sometimes drive is visible under drives but when trying to programaticly write to it, it gives you a msg box error wich freezes the application until user presses the ok button. Is there any built in function that would check if drive is writable without the annoying error box?

I tried trycopy already and returns the same msgbox error :(

Thanks!

도움이 되었습니까?

해결책

Try calling SetErrorMode( SEM_FAILCRITICALERRORS) to prevent the error messageboxes from popping up.

http://msdn.microsoft.com/en-us/library/ms680621(VS.85).aspx

다른 팁

You can set a reference to Microsoft Scripting Runtime.

You can then use code like:

Dim FSO as New FileSystemObject
Dim clsDrive as Scripting.Drive

Set clsDrive=FSO.GetDrive("C")

The Drive class has a FreeSpace Property, which will be zero if the drive is not writeable.

Moreover there is a Scripting.Folder class that you can het by using FSO.GetFolder() that has an Attributes property, which consists of flags of type FileAttribute. You can use code like

clsFolder.Attributes And FileAttribute.Readonly to check for err... ReadOnlyness ;-)

Call GetVolumeInformation() and check FILE_READ_ONLY_VOLUME in the returned flags parameter.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top