unc

Get UNC path from a local path or mapped path

送分小仙女□ 提交于 2019-12-01 16:50:37
In Delphi there is a function ExpandUNCFileName that takes in a filename and converts it into the UNC equivalent. It expands mapped drives and skips local and already expanded locations. Samples C:\Folder\Text.txt -> C:\Folder\Text.txt L:\Folder\Sample.txt -> \\server\Folder1\Folder\Sample.txt Where L: is mapped to \\server\Folder1\ \\server\Folder\Sample.odf -> \server\Folder\Sample.odf Is there a simple way to do this in C# or will I have to use windows api call WNetGetConnection and then manually check the ones that wouldn't get mapped? There is no built-in function in the BCL which will do

Python 2: Get network share path from drive letter

烈酒焚心 提交于 2019-12-01 16:16:34
If I use the following to get the list of all connected drives: available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)] How do I get the UNC path of the connected drives? os.path just returns z:\ instead of \share\that\was\mapped\to\z Use win32wnet from pywin32 to convert your drive letters. For example: import win32wnet import sys print(win32wnet.WNetGetUniversalName(sys.argv[1], 1)) This gives me something like this when I run it: C:\test>python get_unc.py i:\some\path \\machine\test_share\some\path Using ctypes and the code shown in the first answer in

can record unc connection?

眉间皱痕 提交于 2019-12-01 13:54:41
The Pc I use have an UNC file. I'm in a Network with other people. Every other can open the file by tipping in the adress line \\file. Know I want to write a c# programm in Vs2010 which watch over the file I use Win7 32bit. If any one Open the file the programm shall write in a Logfile that someone has open my file. I tried to use the FileSystemWatcher but this only look for changes/saves/cration but not for Opening. I read somthing about "auditing" and that I'm be able to do that(watch over my unc file) with this(auditing).But i tried to find out how to use auditing in c# but i found not much

Get 'unc' path in OSX of mounted share

↘锁芯ラ 提交于 2019-12-01 13:20:53
In python I am trying to get the 'unc' path or server path of a mounted share. So I have a mounted share of: /Volumes/D How do I resolve to this with Python: //192.168.0.7/D Cheers. After looking into df , I came up with this which works excellent on OSX: from subprocess import Popen, PIPE df = Popen('df -P /Volumes/link/to/some/folder', shell=True, stdout=PIPE) serverAddress = df.stdout.readlines()[1:][0] serverAddress = serverAddress.split('@')[1] serverAddress = serverAddress.split('/')[0] print serverAddress 来源: https://stackoverflow.com/questions/24848211/get-unc-path-in-osx-of-mounted

can record unc connection?

谁说我不能喝 提交于 2019-12-01 13:10:55
问题 The Pc I use have an UNC file. I'm in a Network with other people. Every other can open the file by tipping in the adress line \\file. Know I want to write a c# programm in Vs2010 which watch over the file I use Win7 32bit. If any one Open the file the programm shall write in a Logfile that someone has open my file. I tried to use the FileSystemWatcher but this only look for changes/saves/cration but not for Opening. I read somthing about "auditing" and that I'm be able to do that(watch over

Are Extended-Length Paths safe to use?

一世执手 提交于 2019-12-01 08:52:15
I just stumbled on this article on MSDN that says a path can be 259 characters + NUL termination, but if you prefix it with "\\?\" WinAPI allows you to use the maximum total path length of 32,767 characters. Eager to see it working I tried using that prefix from Explorer (On XP SP3) but it doesn't work at all (on any path). If you put \\?\C:\Path\to\an\existing.file on explorer's bar, it will give the "file not found" error. So I'm confused. Can I code something for (non-ancient) Windows that makes full use of the mentioned path size on NTFS? Why Explorer doesn't use it? There is a SET of API

Are Extended-Length Paths safe to use?

ぐ巨炮叔叔 提交于 2019-12-01 06:52:06
问题 I just stumbled on this article on MSDN that says a path can be 259 characters + NUL termination, but if you prefix it with "\\?\" WinAPI allows you to use the maximum total path length of 32,767 characters. Eager to see it working I tried using that prefix from Explorer (On XP SP3) but it doesn't work at all (on any path). If you put \\?\C:\Path\to\an\existing.file on explorer's bar, it will give the "file not found" error. So I'm confused. Can I code something for (non-ancient) Windows that

How to retrieve the UNC path instead of mapped drive path from JFileChooser

别等时光非礼了梦想. 提交于 2019-12-01 05:54:53
问题 Just wondering if there is a way to return back the UNC path from a file chosen with JFileChooser. The file that I would be selecting would reside on a mapped drive that has a UNC path. Right now, I can only seem to pull back the drive letter of a mapped drive. 回答1: From https://stackoverflow.com/users/715934/tasoocoo I ended up finding a solution that executes the NET USE command: filePath = fc.getSelectedFile().getAbsolutePath(); Runtime runTime = Runtime.getRuntime(); Process process =

How to read files from a UNC-specified directory in R?

萝らか妹 提交于 2019-11-30 23:15:31
Is it possible to read files from a UNC-specified directory in R ? I'd like to do it without using any packages beyond the base installation. UNC names work fine, you just have to escape them correctly. This works for me: read.csv('\\\\COMPUTER\\Directory\\file.txt') adding to nograpes answer ... you can avoid the escaping ugliness by using forward slashes ... this works as well read.csv('//COMPUTER/Directory/file.txt') a slightly more cross-platform approach # the two '' are required to represent the two leading slashes of the UNC path read.csv(file.path('', '', 'COMPUTER', 'Directory' 'file

Give FullTrust to UNC share for Visual Studio 2012 and .Net 4.0

﹥>﹥吖頭↗ 提交于 2019-11-30 20:31:04
Everytime I try to open a solution that is located on a UNC share I get this dialog: I've tried using the caspol.exe utility that Hanselman talks about here , but it doesn't seem to work. At least not for a .Net 4 project runing in Visual Studio 2012. Running the .NET 4 version of caspol with the same arguments I get this message: WARNING: The .NET Framework does not apply CAS policy by default. Any settings shown or modified by CasPol will only affect applications that opt into using CAS policy. Please see http://go.microsoft.com/fwlink/?LinkId=131738 for more information. I followed that