CreateAndOpenUniqueTempFile() public static method

Create a pseudo-random filename, suitable for use as a temporary file, and open it.

The System.IO.Path.GetRandomFileName() method is not available on the Compact Framework, so this library provides its own substitute on NETCF.

This method produces a filename of the form DotNetZip-xxxxxxxx.tmp, where xxxxxxxx is replaced by randomly chosen characters, and creates that file.

public static CreateAndOpenUniqueTempFile ( string dir, Stream &fs, string &filename ) : void
dir string
fs Stream
filename string
return void
Example #1
0
        private void _SetWriteStream(uint increment)
        {
            if (_innerStream != null)
            {
#if NETCF
                _innerStream.Close();
#else
                _innerStream.Dispose();
#endif
                if (File.Exists(CurrentName))
                {
                    File.Delete(CurrentName);
                }
                File.Move(_currentTempName, CurrentName);
                // Console.WriteLine("ZSS: SWS close ({0})",
                //                   Path.GetFileName(CurrentName));
            }

            if (increment > 0)
            {
                CurrentSegment += increment;
            }

            SharedUtilities.CreateAndOpenUniqueTempFile(_baseDir,
                                                        out _innerStream,
                                                        out _currentTempName);

            // Console.WriteLine("ZSS: SWS open ({0})",
            //                   Path.GetFileName(_currentTempName));

            if (CurrentSegment == 0)
            {
                _innerStream.Write(BitConverter.GetBytes(ZipConstants.SplitArchiveSignature), 0, 4);
            }
        }
Example #2
0
 // Token: 0x06000689 RID: 1673 RVA: 0x0003A820 File Offset: 0x00038A20
 private void _SetWriteStream(uint increment)
 {
     if (this._innerStream != null)
     {
         this._innerStream.Dispose();
         if (File.Exists(this.CurrentName))
         {
             File.Delete(this.CurrentName);
         }
         File.Move(this._currentTempName, this.CurrentName);
     }
     if (increment > 0U)
     {
         this.CurrentSegment += increment;
     }
     SharedUtilities.CreateAndOpenUniqueTempFile(this._baseDir, out this._innerStream, out this._currentTempName);
     if (this.CurrentSegment == 0U)
     {
         this._innerStream.Write(BitConverter.GetBytes(134695760), 0, 4);
     }
 }