/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use EncryptFile.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)]
private static partial bool EncryptFilePrivate(string lpFileName);
+#else
+ [DllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool EncryptFilePrivate(string lpFileName);
+#endif
internal static bool EncryptFile(string path)
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DecryptFile.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)]
- private static partial bool DecryptFileFilePrivate(string lpFileName, int dwReserved);
+ private static partial bool DecryptFileFilePrivate(
+#else
+ [DllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool DecryptFileFilePrivate(
+#endif
+ string lpFileName,
+ int dwReserved);
internal static bool DecryptFile(string path)
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CopyFileEx.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode)]
private static partial bool CopyFileExPrivate(
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool CopyFileExPrivate(
+#endif
string src,
string dst,
IntPtr progressRoutine,
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateFile.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
private static unsafe partial IntPtr CreateFilePrivate_IntPtr(
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
+ private static unsafe extern IntPtr CreateFilePrivate_IntPtr(
+#endif
string lpFileName,
int dwDesiredAccess,
FileShare dwShareMode,
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DeleteFile.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode)]
private static partial bool DeleteFilePrivate(string path);
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool DeleteFilePrivate(string path);
+#endif
internal static bool DeleteFile(string path)
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DeleteVolumeMountPoint.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode)]
internal static partial bool DeleteVolumeMountPointPrivate(string mountPoint);
-
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", SetLastError = true, CharSet = CharSet.Unicode)]
+ internal static extern bool DeleteVolumeMountPointPrivate(string mountPoint);
+#endif
internal static bool DeleteVolumeMountPoint(string mountPoint)
{
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial int GetLogicalDrives();
+#else
+ [DllImport(Libraries.Kernel32, SetLastError = true)]
+ internal static extern int GetLogicalDrives();
+#endif
}
}
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true)]
- internal static unsafe partial bool GetVolumeInformation(string drive, char* volumeName, int volumeNameBufLen, int* volSerialNumber, int* maxFileNameLen, out int fileSystemFlags, char* fileSystemName, int fileSystemNameBufLen);
+ internal static unsafe partial bool GetVolumeInformation(
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "GetVolumeInformationW", CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static unsafe extern bool GetVolumeInformation(
+#endif
+ string drive,
+ char* volumeName,
+ int volumeNameBufLen,
+ int* volSerialNumber,
+ int* maxFileNameLen,
+ out int fileSystemFlags,
+ char* fileSystemName,
+ int fileSystemNameBufLen);
internal const uint FILE_SUPPORTS_ENCRYPTION = 0x00020000;
}
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use MoveFile.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode)]
- private static partial bool MoveFileExPrivate(string src, string dst, uint flags);
+ private static partial bool MoveFileExPrivate(
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "MoveFileExW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool MoveFileExPrivate(
+#endif
+ string src, string dst, uint flags);
/// <summary>
/// Moves a file or directory, optionally overwriting existing destination file. NOTE: overwrite must be false for directories.
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use RemoveDirectory.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)]
private static partial bool RemoveDirectoryPrivate(string path);
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "RemoveDirectoryW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool RemoveDirectoryPrivate(string path);
+#endif
internal static bool RemoveDirectory(string path)
{
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode)]
private static partial bool ReplaceFilePrivate(
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "ReplaceFileW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool ReplaceFilePrivate(
+#endif
string replacedFileName, string replacementFileName, string? backupFileName,
int dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved);
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use SetFileAttributes.
/// </summary>
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode)]
- private static partial bool SetFileAttributesPrivate(string name, int attr);
+ private static partial bool SetFileAttributesPrivate(
+#else
+ [DllImport(Libraries.Kernel32, EntryPoint = "SetFileAttributesW", SetLastError = true, CharSet = CharSet.Unicode)]
+ private static extern bool SetFileAttributesPrivate(
+#endif
+ string name,
+ int attr);
internal static bool SetFileAttributes(string name, int attr)
{
{
internal static partial class Kernel32
{
+#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
- internal static unsafe partial bool SetFileInformationByHandle(SafeFileHandle hFile, int FileInformationClass, void* lpFileInformation, uint dwBufferSize);
+ internal static unsafe partial bool SetFileInformationByHandle(
+#else
+ [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
+ internal static unsafe extern bool SetFileInformationByHandle(
+#endif
+ SafeFileHandle hFile,
+ int FileInformationClass,
+ void* lpFileInformation,
+ uint dwBufferSize);
}
}