public override File Create() { // creates the parent if it doesnt exist if (!Parent.Exists()) { Parent.Create(); } var handle = LongPathFile.GetFileHandle(Path, FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite, FileOptions.None); handle.Dispose(); return(this); }
// http://stackoverflow.com/questions/8991192/check-filesize-without-opening-file-in-c public override long GetSize() { using (var fh = LongPathFile.GetFileHandle(Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, FileOptions.None)) { if (fh.IsInvalid) { throw LongPathCommon.GetExceptionFromLastWin32Error(); } long size; if (NativeMethods.GetFileSizeEx(fh, out size)) { return(size); } throw LongPathCommon.GetExceptionFromLastWin32Error(); } }