473,626 Members | 3,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checking if can write to a drive

Trying to check if a drive is writable. Can do it by trying to create a directory using DirectoryInfo class then checking err.number but looking for a more elegant way. Tried DirectoryInfo.A ttributes.ReadO nly but always get a FileAttributes. ReadOnly result. Any help would be appreciated.
--
Dennis in Houston
Nov 22 '05 #1
1 1735
The simplest way is trying to create a temporary file using something like:

File.Create(pat hToTest + Guid.Create()+" .tmp")

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Dennis" <De****@discuss ions.microsoft. com> schrieb im Newsbeitrag
news:55******** *************** ***********@mic rosoft.com...
Trying to check if a drive is writable. Can do it by trying to create a directory using DirectoryInfo class then checking err.number but looking for
a more elegant way. Tried DirectoryInfo.A ttributes.ReadO nly but always get
a FileAttributes. ReadOnly result. Any help would be appreciated. --
Dennis in Houston

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
354
by: Dennis | last post by:
Trying to check if a drive is writable. Can do it by trying to create a directory using DirectoryInfo class then checking err.number but looking for a more elegant way. Tried DirectoryInfo.Attributes.ReadOnly but always get a FileAttributes.ReadOnly result. Any help would be appreciated. -- Dennis in Houston
67
4243
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
4
7590
by: papillonimages | last post by:
Please can someone help me, I am trying to write a Regular Expression check for a valid (Windows) filename (cant believe I couldnt find one on the net already?!?!?!). Anyway, here is what I have but it doesnt fully work - e.g. it allows the use of quotes, and the ampersand in some positions and I just cant correct it??! Sorry for being a dull newbie. TIA. -------------------------------------------------
0
2854
by: Jeff | last post by:
I am trying to write some C# code that will allow me to determine if the current user running my application has "write" permissions to a particular folder. However, I can't seem to get it to work. In the code snippet I've included below, it always returns "true" whether the folder/file exists or not (let alone whether or not they have permissions). Any ideas? <<< BEGIN CODE SNIPPET >>>
0
989
by: Tony | last post by:
I know what my drive type is, e.g. cd rom or removable media. Is there a way to query the drive to see if it contains media, and one step further, whether it is writeable. This applies for any removeable drive, and CD drives. Thanks Tony
0
945
by: Dennis | last post by:
Some time ago, I posed a queston in this newsgroup regarding how to determine if a drive was readonly. The only way I had found was to try to create a directory or file then chedk if an error was encountered. The replies were that this was acceptable. However, it takes time to do this. Since I found a way, which probably most know already but for those new to VB.Net, here it is: 'Note r is a string equal to root directory on drive...
5
5098
by: Sumana | last post by:
Hi All, We developed our project on VC++.Net console application to create image of disk and to write the image We are having problem with reading and writing the sector beyond 6GB Disk or Partition we are using ReadFile , WriteFile and setFilePointerEx to read and write the sectors and we are reading/writing 102400 sectors together, even we have reduced the sectors still it is not able to read or write, our program is working fine...
0
798
by: sdf.ska | last post by:
I have a simple function that returns a boolean depending on if a file is in use on a local drive. (looking to see if a file is finished being written to by another app) Works great from a local drive but when I send it a unc path to the same folder, it does not work. my question is Why? and or if anyone has a better solution to see if a file is being used exclusively on a network share, i would be interested to know. Thanks here is the...
125
6541
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this problem. http://www.jilp.org/vol9/v9paper10.pdf Specifically, they measured the overhead of a bounds
12
455
by: Joe Strout | last post by:
On Nov 12, 2008, at 10:45 AM, Tim Rowe wrote: Because if I write a method with the intention of treating the arguments like strings in various ways (slicing, combining with other strings, printing to stdout or writing to a file, etc. etc.), and some idiot (i.e. me six weeks later or long after I should have gone to bed) manages to accidentally pass in something else, then I want my program to blow up right away, not plant a roadside...
0
8266
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8199
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8365
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.