XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
functions FolderExists() and FileExists() causes an error https://www.bbs.xwidget.com/viewtopic.php?f=3&t=2998 |
Page 1 of 1 |
Author: | stormitornado [ April 28th, 2013, 6:17 am ] |
Post subject: | functions FolderExists() and FileExists() causes an error |
functions FolderExists() and FileExists() causes an error "Insert disk in drive X:", when check an empty dvdrom. I don't know, is this a bug, but it causes problems I've tried to use DiskIsReady("") function, but I didn't understand, how to use it. |
Author: | digigamer [ April 28th, 2013, 5:27 pm ] |
Post subject: | Re: functions FolderExists() and FileExists() causes an erro |
This isn't a bug. That's standard windows practice. If some drive is not ready, no API operation is allowed on it. Code: if(DiskReady("DRIVE:")) { //some stuff } else { //disk not ready } For more control, you can use file system object. See MSDN for more details |
Author: | stormitornado [ April 29th, 2013, 10:10 pm ] |
Post subject: | Re: functions FolderExists() and FileExists() causes an erro |
When I use DiskIsReady("Drive:") function, it cause an error "Runtime error: the existence of an object is expected" (Translated from Russian) |
Author: | Tony [ April 30th, 2013, 3:08 am ] |
Post subject: | Re: functions FolderExists() and FileExists() causes an erro |
Hi, you can uses the DiskCore, and set disk name with Code: diskcore1.cmd(null, "diskname=c"); Code: if(diskcore1.IsBlank) { //the disk is blank or not exists } else { } Code: if(diskcore1.DiskType<2) { alert("disk not exit"); } Or, you can use ActiveX object "FSO" function "DriverExists" and get the disk type Code: var fso = new ActiveXObject("Scripting.FileSystemObject");
if( ! fso.DriveExists("d") ) alert("Dirver D is not Exists"); |
Author: | digigamer [ April 30th, 2013, 8:56 pm ] |
Post subject: | Re: functions FolderExists() and FileExists() causes an erro |
stormitornado wrote: When I use DiskIsReady("Drive:") function, it cause an error "Runtime error: the existence of an object is expected" (Translated from Russian) Ok... As I expected.. then this is what you need http://msdn.microsoft.com/en-us/library/x681abd9(v=vs.84).aspx Code: var fso = new ActiveXObject("Scripting.FileSystemObject"); var disk = fso.GetDrive("J:"); //change with your drive if(disk.IsReady) { //disk is ready and contains media } else { //disk not ready... } I don't know why but I too faced problems with XWidget built-in DiskIsReady(). This is a bug... needs to be fixed. Meanwhile ActiveX is the only workaround. |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |