Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Visual Studio 2010 - determine remote share/path in use

Posted on 2012-09-21
2
Medium Priority
?
249 Views
Last Modified: 2012-12-18
I have a console app I'm working on where I retrieve a remote share/path.
Whether the user data on that server is a share, or not, I want to determine if the user is using the data.
In the case of a share, the path would be \\server\userID$
In the other instance, the user would be setup on folder redirection, and their data path would be \\server\frdata$\userID (share would be frdata$, but the userID would not be a share, simply a subfolder in the share).

I think I can perform the logic for the above, but I need to know how I would determine if the parent folder (or anything therein) is in use.  Locally on the console, I would bring up fsmgmt.msc and check the Open Files listings for that path...

I found vbscript code (http://blogs.technet.com/b/heyscriptingguy/archive/2005/02/16/how-can-i-list-open-sessions-and-open-files-on-a-computer.aspx), but wanted to know if there was anything suited for vb.net that I could use instead...?
0
Comment
Question by:sirbounty
2 Comments
 
LVL 1

Accepted Solution

by:
koenigbr earned 1500 total points
ID: 38438346
Folders dont have any real state on if they are in use or not. If a file in the folder is in use, then the folder can't be moved, renamed, or deleted..

From http://stackoverflow.com/questions/1079036/vb-net-3-5-check-if-file-is-in-use
Public Function FileInUse(ByVal sFile As String) As Boolean 
 Dim thisFileInUse As Boolean = False 
 If System.IO.File.Exists(sFile) Then 
     Try 
       Using f As New IO.FileStream(sFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None) 
                ' thisFileInUse = False 
       End Using 
     Catch 
       thisFileInUse = True 
     End Try 
 End If 
 Return thisFileInUse 
End Function 

Open in new window


Just a note though, some applications like Notepad only have the file open for a limited amount of time.  Notepad actually just opens the file and dumps the text into memory.
0
 
LVL 67

Author Comment

by:sirbounty
ID: 38444445
Surely there's a way to get at that list of open files and just filter out any that have the user's path in there?
I can view it in the Shared Folders applet, so it's being stored somewhere, I would think...?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question