473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.Attributes.ReadOnly but always get a FileAttributes.ReadOnly result. Any help would be appreciated.
--
Dennis in Houston
Nov 22 '05 #1
1 1724
The simplest way is trying to create a temporary file using something like:

File.Create(pathToTest + Guid.Create()+".tmp")

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Dennis" <De****@discussions.microsoft.com> schrieb im Newsbeitrag
news:55**********************************@microsof t.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.Attributes.ReadOnly 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
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...
67
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. ...
4
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...
0
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...
0
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...
0
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...
5
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...
0
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...
125
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...
12
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,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.