Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ VolumeLabel

unsafe string System.IO.DriveInfo.VolumeLabel
getset

Definition at line 104 of file DriveInfo.cs.

105 {
106 get
107 {
108 char* ptr = stackalloc char[261];
110 {
111 if (!global::Interop.Kernel32.GetVolumeInformation(Name, ptr, 261, null, null, out var _, null, 0))
112 {
113 throw Error.GetExceptionForLastWin32DriveError(Name);
114 }
115 }
116 return new string(ptr);
117 }
118 [SupportedOSPlatform("windows")]
120 set
121 {
122 uint lpOldMode;
123 bool flag = global::Interop.Kernel32.SetThreadErrorMode(1u, out lpOldMode);
124 try
125 {
126 if (!global::Interop.Kernel32.SetVolumeLabel(Name, value))
127 {
129 if (lastPInvokeError == 5)
130 {
131 throw new UnauthorizedAccessException(System.SR.InvalidOperation_SetVolumeLabelFailed);
132 }
133 throw Error.GetExceptionForWin32DriveError(lastPInvokeError, Name);
134 }
135 }
136 finally
137 {
138 if (flag)
139 {
140 global::Interop.Kernel32.SetThreadErrorMode(lpOldMode, out var _);
141 }
142 }
143 }
144 }
static string InvalidOperation_SetVolumeLabelFailed
Definition SR.cs:16
Definition SR.cs:7
static System.IO.DisableMediaInsertionPrompt Create()