473,396 Members | 2,021 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,396 software developers and data experts.

Determining if a file string points at a drive, a path, or a file, or an onion.

Subject says it all really.
I'm being passed a string, and I'm wondering if theres an easy
way to determine what exactly the string points at?
Cheers
Chris.

Mar 21 '06 #1
2 1657
On 21 Mar 2006 11:09:22 -0800, theinvisibleGhost wrote:
Subject says it all really.
I'm being passed a string, and I'm wondering if theres an easy
way to determine what exactly the string points at?


Depends on what you really want to do. If you want to check that your
string is the path of an existing file on your hard drive or on a network
drive, you could use File.Exist() (and handle the exceptions in case the
string is not a valid path string). For drives and directories, use
Directory.Exist(). The other methods of the Directory class will help you
to determine if your dealing with a path to a drive or to a folder. For
Url, use the Uri class and catch exceptions in case the string is not a
valid Uri.

If you just want to now wether the string is a valid path string (even if
it doesn't point to any file of folder actually existing on your hard
drive), then you could use the various methods of the Path class to do
that.

Else, you can always roll on your own regex to parse the string (actually,
there are probably many examples of regex that could do that on the web)

For onions though i'm not too sure.
Mar 21 '06 #2
Ok I'll try those.
Thanks
:-)

Mar 21 '06 #3

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

Similar topics

2
by: allyn44 | last post by:
Hi, I have a small databse that outputs 2 excel files to a folder. DoCmd.TransferSpreadsheet acExport, , "randtrack",_ "C:\randomization\Trackrandomization.xls" The person wants to put the...
11
by: Wilsoch | last post by:
Long story short: My Access developer is letting me down. He doesn't really know VB and he can't figure out how to do what I need. Situation: Access database that will be used locally on...
1
by: JuneCleaver | last post by:
Hello, I have been digging into writing into a file with the dot net framework. There is a lot of information on it. I have a web application and I want to write to a log file when an...
5
by: wo20051223 | last post by:
Deleting some files with C# fails with "Access to the path 'X' is denied". I have files copied from a CD that I burned (and not locked by a process) and a text file that I created in Windows...
0
by: smanisankar | last post by:
hi, the following is the full page code for uploading a file to server. since i got no idea to overwrite the file, i want delete the file if the file is already uploaded. i got the folder name...
11
by: trs-ggcsea | last post by:
Hi, I am reading a file from a UNC path in my Visual studio 2005 C# (.NET 2) program and getting an access denied exception. I am unsure if this access denied is due to the .NET security...
2
by: jlacefie | last post by:
Hello, I am having trouble with the following code using ASP.Net 2.0. I recieve an error on the line File.OpenRead(fPath) stating could not find file . The fPath comes from a textbox control...
1
by: tanya.wang | last post by:
I want to access files from a remote server so I mapped it in my server under z:\ for \\myserver\web\mysite\images\ I added this UNC path to my IIS virtual directory and name it as "upload" but I...
1
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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,...

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.