![](/img/trans.png)
[英]How do I find the target of a Windows App Execution Alias in C#/Win32 api?
[英]Need to use win32 api to copy files in c# - how do I do this?
我正在嘗試復制一些文件,有時名稱的長度超過了 System.IO.File.Copy 方法可以接受的長度(根據拋出的異常,為 260 個字符)
根據我所做的研究,我應該能夠將 win32 api 的文件方法與路徑前的 \?\ 結合使用以獲得 32,000 個字符的限制,但我不確定我需要導入的巫術方法。
有人可以幫我弄這個嗎? 我正在尋找類似的東西(顯然是不同的 function,但你明白了):
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
static extern SafeFileHandle CreateFileW(string lpFileName, uint dwDesiredAccess,
uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition,
uint dwFlagsAndAttributes, IntPtr hTemplateFile);
[DllImport("kernel32.dll",
CharSet = CharSet.Unicode,
CallingConvention = CallingConvention.StdCall,
SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool CopyFile(
[MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName,
[MarshalAs(UnmanagedType.LPWStr)] string lpNewFileName,
[MarshalAs(UnmanagedType.Bool)] bool bFailIfExists);
嘗試使用CopyFile 。
對於 PInvoke 語法,您可以查看pinvoke.net 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.