원격 인스턴스의 전체 경로에 대한 때문에이 필요한 이유를 나는 상상할 수 없다는 \ danas-PC의 \의 PublicDoc입니다하지만 당신은 당신의 상상을 할 수 있다면 이런 식으로 뭔가를 건의 할 것 번창 :
(1) 공유 폴더 내의 원격 컴퓨터에서 작은 스크립트를 삭제할 수 있습니다. 실행되는 경우 전체 경로를 반환합니다. 당신은 Windows 또는 리눅스 환경에 대한 적절한 코딩을 검색해야하며 실행 권한이나 권리가 필요합니다. 예를 들어 Windows에서 vbscrit 또는 cscript와 Linux에서 .sh 스크립트를 가질 수 있습니다.
또한 원격 호스트의 관점에서 볼 때 전체 경로는 \ NAME-OR-IP \ Path \에서 \ Folder \ 또는 \ File입니다. 원격 연결의 경우 전체 경로입니다)
UPDATE : 아래의 코멘트에 따라 는,이 다음
- 을하는 전체 스크립트는 현재의 전체 경로를 검색하는 그 코드와 VBScript를 새로 만듭니다
- 은 파일을 복사합니다. 네트워크 원하는 경로로
- 는 VBScript를을 실행하고 결과를 다시 읽어
- 는 가정하면 VBScript를
를 삭제 : 당신이
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace GetNetworkFullPath
{
class Program
{
static void Main(string[] args)
{
var networkFolder = "\\\\REMOTE-PC-NAME\\SharedFolder";
var nameOfVBScript = "capturepath.vbs";
var vbsOutput = "";
//Get the name of the current directory
var currentDirectory = Directory.GetCurrentDirectory();
Console.WriteLine("Current Dir: " + currentDirectory);
//1. CREATE A VBSCRIPT TO OUTPUT THE PATH WHERE IT IS PRESENT
//Ref. https://stackoverflow.com/questions/2129327/how-to-get-the-fully-qualified-path-for-a-file-in-vbscript
var vbscriptToExecute = "Dim folderName \n" +
"folderName = \"\" \n" +
"Dim fso \n" +
"Set fso = CreateObject(\"Scripting.FileSystemObject\") \n" +
"Dim fullpath \n" +
"fullpath = fso.GetAbsolutePathName(folderName) \n" +
"WScript.Echo fullpath \n";
//Write that script into a file into the current directory
System.IO.File.WriteAllText(@""+ nameOfVBScript + "", vbscriptToExecute);
//2. COPY THE CREATED SCRIPT INTO THE NETWORK PATH
//Ref. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-copy-delete-and-move-files-and-folders
string sourceFile = System.IO.Path.Combine(currentDirectory, nameOfVBScript);
string destFile = System.IO.Path.Combine(networkFolder, nameOfVBScript);
System.IO.File.Copy(sourceFile, destFile, true);
//3. EXECUTE THAT SCRIPT AND READ THE OUTPUT
//Ref. https://stackoverflow.com/questions/27050195/how-do-i-get-the-output-from-my-vbscript-console-using-c
Process scriptProc = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.WorkingDirectory = @"" + networkFolder + "";
info.FileName = "Cscript.exe";
info.Arguments = nameOfVBScript;
info.RedirectStandardError = true;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
info.WindowStyle = ProcessWindowStyle.Hidden;
scriptProc.StartInfo = info;
scriptProc.Start();
scriptProc.WaitForExit();
bool exit = false;
while (!scriptProc.StandardOutput.EndOfStream)
{
vbsOutput = scriptProc.StandardOutput.ReadLine();
}
Console.WriteLine("vbscript says: " + vbsOutput);
//4. DELETE THE FILE YOU JUST COPIED THERE
System.IO.File.Delete(@"" + networkFolder + "\\" + nameOfVBScript);
}
}
}
불행하게도 때 네트워크 폴더에 대한 읽기/쓰기 권한이 원격으로 실행 된 스크립트는 네트워크 경로로 응답합니다. (너무 실망했습니다 ... 정말로 미안 해요! 원격 시스템 외부의 사용자로부터 실행이 일어나기 만하면 해당 인스턴스와 관련된 절대 경로로 응답합니다. 내부 프로세스/사용자가 파일을 실행하고 응용 프로그램에 대한 응답으로 회신해야한다고 생각합니다.

뭔가 더 내일을 생각하려고 내가 운이있어 경우에 어쩌면 다시 답변 해 드리겠습니다.
왜 하시겠습니까? –
그 대답을 주어야겠습니까? https://superuser.com/questions/1146811/getting-real-path-of-file-on-samba-server-from-client – mariozski
나는 당신이 무엇을 요구하고 있는지 이해하지 못합니다. 아니면 그렇지 않을 수도 있습니다.미리 정의 된' $ '공유 이름을 통과하는 파일을 포함하여 서버의 동일한 파일을 참조 할 수있는 UNC 경로가 여러 개 있습니다. 그 중 "진짜"경로를 만드는 것은 무엇입니까? ''공유를 사용하지 못하도록 서버를 설정하면 어떨까요? 질문을 수정하여 모든 경우에 실제로 일어날 것으로 기대되는 이유와 이유를 분명히하십시오. 목표를 달성 할 가능성은 낮지 만 현재 목표가 실제로 무엇인지는 분명하지 않습니다. –