private static OpenFileName GetFileSpecification(string title, IEnumerable <FileSpecification> fileSpecifications) { var ofn = new OpenFileName(); ofn.lStructSize = Marshal.SizeOf(ofn); ofn.lpstrFilter = BuildWindowsFileFilter(fileSpecifications); ofn.lpstrFile = new string(new char[256]); ofn.nMaxFile = ofn.lpstrFile.Length; ofn.lpstrFileTitle = new string(new char[64]); ofn.nMaxFileTitle = ofn.lpstrFileTitle.Length; ofn.lpstrTitle = title; ofn.Flags = OFN_OVERWRITEPROMPT; var extensionHint = fileSpecifications.First().FileExtensions.First(); if (extensionHint.StartsWith(".")) { extensionHint = extensionHint.Substring(1); } ofn.lpstrDefExt = extensionHint; return(ofn); }
private static extern bool GetSaveFileName(ref OpenFileName lpofn);
private static extern bool GetOpenFileName(ref OpenFileName ofn);