Using C#, I would like my application to return whether a folder (with an already known path) is located in a network or in my computer.
How can I do that?
The using statement causes the object itself to go out of scope as soon as Dispose is called. Within the using block, the object is read-only and can't be modified or reassigned. A variable declared with a using declaration is read-only.
The is operator returns true if the given object is of the same type, whereas the as operator returns the object when they are compatible with the given type. The is operator returns false if the given object is not of the same type, whereas the as operator returns null if the conversion is not possible.
The using statement guarantees that the object is disposed in the event an exception is thrown. It's the equivalent of calling dispose in a finally block.
What is the @ symbol in front of variables in C#? From the C# documentation it states that the @ symbol is an Identifier. The prefix “@” enables the use of keywords as identifiers, which is useful when interfacing with other programming languages.
If you are talking about a mapped network drive, you can use the DriveInfo
's DriveType
property:
var driveInfo = new DriveInfo("S:\");
if(driveInfo.DriveType == DriveType.Network)
// do something
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With