GetTempPath() public méthode

public GetTempPath ( ) : string
Résultat string
Exemple #1
0
        public static void DecryptTagFile(string source, string destination, byte[] key, OpCore core)
        {
            int bufferSize = 4096;
            byte[] buffer = new byte[4096]; // needs to be 4k to packet stream break/resume work

            string tempPath = (core != null) ? core.GetTempPath() : destination;
            G2Protocol protocol = (core != null) ? core.Network.Protocol : new G2Protocol();

            using (FileStream tempFile = new FileStream(tempPath, FileMode.Create))
            using (TaggedStream encFile = new TaggedStream(source, protocol))
            using (IVCryptoStream stream = IVCryptoStream.Load(encFile, key))
            {
                int read = bufferSize;
                while (read == bufferSize)
                {
                    read = stream.Read(buffer, 0, bufferSize);
                    tempFile.Write(buffer, 0, read);
                }
            }

            // move to official path
            if (core == null)
                return;

            File.Copy(tempPath, destination, true);
            File.Delete(tempPath);
        }