473,473 Members | 2,138 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to check folder is shared or not?

3 New Member
Using C# for an application in which I am working on, I need to check the
available folder is shared or not. How to check it?

Thanks!
May 4 '10 #1
1 4692
Plater
7,872 Recognized Expert Expert
Well, you could use WMI?

I took this right from the WMI Code Creator(usefull little tool)
Expand|Select|Wrap|Line Numbers
  1.  
  2. using System;
  3. using System.Management;
  4. using System.Windows.Forms;
  5.  
  6. namespace WMISample
  7. {
  8.     public class MyWMIQuery
  9.     {
  10.         public static void Main()
  11.         {
  12.             try
  13.             {
  14.                 ManagementObjectSearcher searcher = 
  15.                     new ManagementObjectSearcher("root\\CIMV2", 
  16.                     "SELECT * FROM Win32_Share"); 
  17.  
  18.                 foreach (ManagementObject queryObj in searcher.Get())
  19.                 {
  20.                     Console.WriteLine("-----------------------------------");
  21.                     Console.WriteLine("Win32_Share instance");
  22.                     Console.WriteLine("-----------------------------------");
  23.                     Console.WriteLine("AccessMask: {0}", queryObj["AccessMask"]);
  24.                     Console.WriteLine("AllowMaximum: {0}", queryObj["AllowMaximum"]);
  25.                     Console.WriteLine("Caption: {0}", queryObj["Caption"]);
  26.                     Console.WriteLine("Description: {0}", queryObj["Description"]);
  27.                     Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);
  28.                     Console.WriteLine("MaximumAllowed: {0}", queryObj["MaximumAllowed"]);
  29.                     Console.WriteLine("Name: {0}", queryObj["Name"]);
  30.                     Console.WriteLine("Path: {0}", queryObj["Path"]);
  31.                     Console.WriteLine("Status: {0}", queryObj["Status"]);
  32.                     Console.WriteLine("Type: {0}", queryObj["Type"]);
  33.                 }
  34.             }
  35.             catch (ManagementException e)
  36.             {
  37.                 MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
  38.             }
  39.         }
  40.     }
  41. }
  42.  
  43.  
Example output:
-----------------------------------
Win32_Share instance
-----------------------------------
AccessMask:
AllowMaximum: True
Caption: License
Description:
InstallDate:
MaximumAllowed:
Name: httproot
Path: C:\inetpub\wwwroot\
Status: OK
Type: 0
So Name and Path are probably your most usefull properties
May 4 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Hubert Wong | last post by:
Hi, I am writing some C# code that moves files from a source folder to a target folder on the same machine. However, if the target folder is a shared folder, using the File.MoveTo method alone...
2
by: Mr. Smith | last post by:
As the subject suggests, If I have a file path; C:\My documents\UMS\Cat1\File.txt and UMS is a shared folder shared as 'UMSPictures', is there any way I can test if each folder in the...
1
by: Jon | last post by:
I have one class file which I would like to share across several asp.net apps in VS 2005. I would like changes I make to that shared file to reflect in all the apps. By default when I add the...
2
by: John | last post by:
Hi, What is best folder to put database (location of database)? This is because when administrator restricts user rights to read (read and execute), and doesn't give permissions to write in C:...
6
by: jzdeng | last post by:
Hi, All I use VS 2005 to create a web service. The web service is used to create a sheared folder. It works fine we I run it from VS 2005. But, when I move it to inetpub, it does not work...
17
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 -...
7
by: Zeb | last post by:
Hi all I've developed a shopping cart in C# and to allow moderators to upload product images, news images and downloadable PDFs, the app creates a folder for each product. I start out with the...
0
by: Tulgaa | last post by:
When i manually create a shared folder, the shared folder was non password protection. but when i create a shared folder from a program, the shared folder is become password protected. I use...
5
by: Web Search Store | last post by:
Hello, I made a web page using visual studio. I also made a public class in the app_code folder called 'allvars' In the main web page durning the page startup, I can refer to public shared...
2
by: aquasudha | last post by:
Dear experts, * I've connected my desktop pc and laptop in a network by using Switch. * Broad band is directly connected with Switch. * Both Laptop and Desktop pc 's IP...
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
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...
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
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...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.