MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / SaveAsFile

Method SaveAsFile

dotnet/src/webdriver/PrintDocument.cs:54–68  ·  view source on GitHub ↗

Saves this as a PDF formatted file, overwriting the file if it already exists. The full path and file name to save the printed document to. If is or whitespace. -or- refers

(string fileName)

Source from the content-addressed store, hash-verified

52 /// <exception cref="DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive.</exception>
53 /// <exception cref="PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length.</exception>
54 public override void SaveAsFile(string fileName)
55 {
56 if (string.IsNullOrEmpty(fileName))
57 {
58 throw new ArgumentException("The file name to be saved cannot be null or the empty string", nameof(fileName));
59 }
60
61 using (MemoryStream imageStream = new MemoryStream(this.AsByteArray))
62 {
63 using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
64 {
65 imageStream.WriteTo(fileStream);
66 }
67 }
68 }
69}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected