Esempio n. 1
0
        public static void CopyFile(string sourcePath, RenderOutputMethod renderOutput, string relativeDestPath,
                                    string mimeType)
        {
            FileIdentification fileIdentificationStatic = FileOutputMethod.GetFileIdentificationStatic(sourcePath);
            FileIdentification fileIdentification       = renderOutput.GetFileIdentification(relativeDestPath);

            if (fileIdentificationStatic.CompareTo(fileIdentification) == 0)
            {
                return;
            }

            Stream stream  = new FileStream(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            Stream stream2 = renderOutput.CreateFile(relativeDestPath, mimeType);

            byte[] buffer = new byte[65536];
            while (true)
            {
                int num = stream.Read(buffer, 0, 65536);
                if (num == 0)
                {
                    break;
                }

                stream2.Write(buffer, 0, num);
            }

            stream.Close();
            stream2.Close();
        }
Esempio n. 2
0
		public static FileIdentification GetFileIdentificationStatic(string fullPathname)
		{
			FileIdentification result;
			try
			{
				FileStream fileStream = File.Open(fullPathname, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
				long length = fileStream.Length;
				fileStream.Close();
				result = new FileIdentification(length);
			}
			catch (FileNotFoundException)
			{
				result = new FileIdentification(-1L);
			}
			catch (DirectoryNotFoundException)
			{
				result = new FileIdentification(-1L);
			}
			return result;
		}
Esempio n. 3
0
        public static FileIdentification GetFileIdentificationStatic(string fullPathname)
        {
            FileIdentification result;

            try
            {
                FileStream fileStream = File.Open(fullPathname, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                long       length     = fileStream.Length;
                fileStream.Close();
                result = new FileIdentification(length);
            }
            catch (FileNotFoundException)
            {
                result = new FileIdentification(-1L);
            }
            catch (DirectoryNotFoundException)
            {
                result = new FileIdentification(-1L);
            }
            return(result);
        }