当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.FileInfo.Create方法代码示例

本文整理汇总了C#中System.IO.FileInfo.Create方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.FileInfo.Create方法的具体用法?C# System.IO.FileInfo.Create怎么用?C# System.IO.FileInfo.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了System.IO.FileInfo.Create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

        public List<string[]> Read()
        {
            try {
                System.IO.FileInfo backlogFile = new System.IO.FileInfo(SQ.Util.Constant.BACKLOG_FILE);
                if (!backlogFile.Exists){
                    backlogFile.Create();
                    return new List<string[]>();
                }

                System.IO.StreamReader sr = new System.IO.StreamReader (SQ.Util.Constant.BACKLOG_FILE);
                Repo.LastSyncTime = backlogFile.LastWriteTime;
                List<string[]> filesInBackLog = new List<string[]>();
                int i = 1;
                while (!sr.EndOfStream) {
                    string [] info = BreakLine (sr.ReadLine (), 5);
                    filesInBackLog.Add (info);
                    i++;
                }
                sr.Dispose();
                sr.Close ();
                return filesInBackLog;
            } catch (Exception e) {
                SQ.Util.Logger.LogInfo("Sync", e);
                return null;
            }
        }
开发者ID:adaptive,项目名称:qloudsync,代码行数:26,代码来源:BacklogSynchronizer.cs

示例2: _model_ChangedTaskStatus

        void _model_ChangedTaskStatus(object sender, EventArgs e)
        {
            switch (_model.Status)
            {
                case DownloadStatus.Loading:
                    ImageUrl = _model.ImageInfo.ImageUrl;
                    break;
                case DownloadStatus.Loaded:
                case DownloadStatus.Deleted:
                    var file = new System.IO.FileInfo(string.Format("{0}\\{1}.jpg", _container.ThumbDir.FullName, _model.HashText));
                    if (!file.Exists)
                    {
                        using (var reader = _model.DownloadedTempImageFile.OpenRead())
                        {
                            var dec = System.Windows.Media.Imaging.BitmapDecoder.Create(
                                reader, System.Windows.Media.Imaging.BitmapCreateOptions.None,
                                System.Windows.Media.Imaging.BitmapCacheOption.None);
                            var baseImg = dec.Frames.First();

                            var width = 250;
                            var height = 80;
                            var rate = Math.Max((double)width / baseImg.PixelWidth, (double)height / baseImg.PixelHeight);
                            var transform = new ScaleTransform(rate, rate);
                            var resizeImg = new System.Windows.Media.Imaging.TransformedBitmap(baseImg, transform);
                            var trimmingImg = new System.Windows.Media.Imaging.CroppedBitmap(
                                resizeImg, new System.Windows.Int32Rect(0, 0, width, height));
                            var enc = new System.Windows.Media.Imaging.JpegBitmapEncoder();
                            enc.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(trimmingImg));
                            using (var writer = file.Create())
                                enc.Save(writer);
                        }
                    }
                    ImageThumbPath = new Uri(file.FullName);
                    break;
            }
            DownloadStatus = _model.Status;
        }
开发者ID:namoshika,项目名称:GPlusAutoImageDownloader,代码行数:37,代码来源:JobViewModel.cs

示例3: DumpBody

 /// <summary>
 /// Dumps the body of this entity into a file
 /// </summary>
 /// <param name="path">path of the destination folder</param>
 /// <param name="name">name of the file</param>
 /// <returns><see cref="System.IO.FileInfo" /> that represents the file where the body has been saved</returns>
 public System.IO.FileInfo DumpBody( System.String path, System.String name )
 {
     System.IO.FileInfo file = null;
     if ( name!=null ) {
     #if LOG
         if ( log.IsDebugEnabled )
             log.Debug ("Found attachment: " + name);
     #endif
         name = System.IO.Path.GetFileName(name);
         // Dump file contents
         try {
             System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo ( path );
             dir.Create();
             try {
                 file = new System.IO.FileInfo (System.IO.Path.Combine (path, name) );
             } catch ( System.ArgumentException ) {
                 file = null;
     #if LOG
                 if ( log.IsErrorEnabled )
                     log.Error(System.String.Concat("Filename [", System.IO.Path.Combine (path, name), "] is not allowed by the filesystem"));
     #endif
             }
             if ( file!=null && dir.Exists ) {
                 if ( dir.FullName.Equals (new System.IO.DirectoryInfo (file.Directory.FullName).FullName) ) {
                     if ( !file.Exists ) {
     #if LOG
                         if ( log.IsDebugEnabled )
                             log.Debug (System.String.Concat("Saving attachment [", file.FullName, "] ..."));
     #endif
                         System.IO.Stream stream = null;
                         try {
                             stream = file.Create();
     #if LOG
                         } catch ( System.Exception e ) {
                             if ( log.IsErrorEnabled )
                                 log.Error(System.String.Concat("Error creating file [", file.FullName, "]"), e);
     #else
                         } catch ( System.Exception ) {
     #endif
                         }
                         bool error = !this.DumpBody (stream);
                         if ( stream!=null )
                             stream.Close();
                         stream = null;
                         if ( error ) {
     #if LOG
                             if ( log.IsErrorEnabled )
                                 log.Error (System.String.Concat("Error writting file [", file.FullName, "] to disk"));
     #endif
                             if ( stream!=null )
                                 file.Delete();
                         } else {
     #if LOG
                             if ( log.IsDebugEnabled )
                                 log.Debug (System.String.Concat("Attachment saved [", file.FullName, "]"));
     #endif
                             // The file should be there
                             file.Refresh();
                             // Set file dates
                             if ( this.Header.ContentDispositionParameters.ContainsKey("creation-date") )
                                 file.CreationTime = anmar.SharpMimeTools.SharpMimeTools.parseDate ( this.Header.ContentDispositionParameters["creation-date"] );
                             if ( this.Header.ContentDispositionParameters.ContainsKey("modification-date") )
                                 file.LastWriteTime = anmar.SharpMimeTools.SharpMimeTools.parseDate ( this.Header.ContentDispositionParameters["modification-date"] );
                             if ( this.Header.ContentDispositionParameters.ContainsKey("read-date") )
                                 file.LastAccessTime = anmar.SharpMimeTools.SharpMimeTools.parseDate ( this.Header.ContentDispositionParameters["read-date"] );
                         }
     #if LOG
                     } else if ( log.IsDebugEnabled ) {
                         log.Debug("File already exists, skipping.");
     #endif
                     }
     #if LOG
                 } else if ( log.IsDebugEnabled ) {
                     log.Debug(System.String.Concat ("Folder name mistmatch. [", dir.FullName, "]<>[", new System.IO.DirectoryInfo (file.Directory.FullName).FullName, "]"));
     #endif
                 }
     #if LOG
             } else if ( file!=null && log.IsErrorEnabled ) {
                 log.Error ("Destination folder does not exists.");
     #endif
             }
             dir = null;
     #if LOG
         } catch ( System.Exception e ) {
             if ( log.IsErrorEnabled )
                 log.Error ("Error writting to disk: " + name, e);
     #else
         } catch ( System.Exception ) {
     #endif
             try {
                 if ( file!=null ) {
                     file.Refresh();
                     if ( file.Exists )
                         file.Delete ();
//.........这里部分代码省略.........
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:101,代码来源:SharpMimeMessage.cs

示例4: buttonSaveWhiteRefImage_Click

        private void buttonSaveWhiteRefImage_Click( object sender, EventArgs e )
        {
            string	OldFileName = GetRegKey( "LastWhiteReferenceImageFilename", m_ImageFileName != null ? System.IO.Path.Combine( System.IO.Path.GetDirectoryName( m_ImageFileName.FullName ), System.IO.Path.GetFileNameWithoutExtension( m_ImageFileName.FullName ) + ".png" ) : m_ApplicationPath );
            saveFileDialogWhiteRefImage.InitialDirectory = System.IO.Path.GetDirectoryName( OldFileName );
            saveFileDialogWhiteRefImage.FileName = System.IO.Path.GetFileName( OldFileName );

            if ( saveFileDialogWhiteRefImage.ShowDialog( this ) != DialogResult.OK )
             				return;

            SetRegKey( "LastWhiteReferenceImageFilename", saveFileDialogWhiteRefImage.FileName );
            SetRegKey( "ReloadWhiteReferenceImageOnStartup", "true" );

            try
            {
                System.IO.FileInfo	WhiteRefFileName = new System.IO.FileInfo( saveFileDialogWhiteRefImage.FileName );

                using ( System.IO.FileStream S = WhiteRefFileName.Create() )
                    m_CalibrationDatabase.WhiteReferenceImage.Save( S, ImageUtility.Bitmap.FILE_TYPE.PNG, ImageUtility.Bitmap.FORMAT_FLAGS.GRAY | ImageUtility.Bitmap.FORMAT_FLAGS.SAVE_16BITS_UNORM, null );
            }
            catch ( Exception _e )
            {
                MessageBox( "An error occurred while saving the white reference image:\r\n\r\n", _e );
            }
        }
开发者ID:Patapom,项目名称:GodComplex,代码行数:24,代码来源:Form1.cs

示例5: OnLoad

        protected unsafe override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            using ( fftwlib.FFT2D FFT = new fftwlib.FFT2D( 256, 256 ) )
            {
                // Build the source data
            //				FillInput( FFT.Input );

                {
                    const double	Lx = 400.0;
                    const double	Lz = Lx;

                    const double	WindAngle = 45.0 * Math.PI / 180.0;
                    const double	WindVelocity = 20.0;

                    double	Wx = Math.Cos( WindAngle );
                    double	Wz = Math.Sin( WindAngle );

                    double	U1, U2, fX, fZ;

                    Random	RNG = new Random( 1 );

                    FFT.FillInputFrequency( ( int Fx, int Fy, out float r, out float i ) => {
                        double	kx = (2.0 * Math.PI / Lx) * Fx;
                        double	kz = (2.0 * Math.PI / Lz) * Fy;

                        // Build white gaussian noise
                        // (source: http://www.dspguru.com/dsp/howtos/how-to-generate-white-gaussian-noise)
                        U1 = 1e-10 + RNG.NextDouble();
                        U2 = RNG.NextDouble();
                        fX = Math.Sqrt(-2.0 * Math.Log( U1 )) * Math.Sin( 2.0 * Math.PI * U2 );
                        U1 = 1e-10 + RNG.NextDouble();
                        U2 = RNG.NextDouble();
                        fZ = Math.Sqrt(-2.0 * Math.Log( U1 )) * Math.Sin( 2.0 * Math.PI * U2 );

            fX = fZ = 1.0;

                        // Build Phillips spectrum
                        double	SqrtPhillips = Math.Sqrt( Phillips( kx, kz, WindVelocity, Wx, Wz ) );
                        r = (float) (1.0 / Math.Sqrt( 2.0 ) * fX * SqrtPhillips);
                        i = (float) (1.0 / Math.Sqrt( 2.0 ) * fZ * SqrtPhillips);

            r = (float) (U1);// * Math.Exp( -0.001 * Math.Abs( Fx ) ));
            i = 0.0f;//(float) U2;

            // r = 0.0;
            // for ( int j=1; j < 100; j++ )
            // 	r += 0.25 * Math.Cos( 2.0 * Math.PI * -j * (X+2*Y) / 256.0 ) / j;
            // i = 0.0;

            // r = Math.Exp( -0.1 * kx );
            // i = Math.Exp( -0.1 * kz );

                        } );
                }

                // Fill in bitmap
                outputPanelFrequency.FillBitmap( ( int _X, int _Y, int _Width, int _Height ) =>
                    {
                        int	X = 256 * _X / _Width;
                        int	Y = 256 * _Y / _Height;
                        byte	R = (byte) (255 * Math.Min( 1.0, Math.Abs( FFT.Input[2*(256*Y+X)+0] )));
                        byte	I = (byte) (255 * Math.Min( 1.0, Math.Abs( FFT.Input[2*(256*Y+X)+1] )));

                        return 0xFF000000 | (uint) ((R << 16) | (I << 8));
                    } );

                // Inverse FFT
                FFT.InputIsSpatial = false;	// We fed frequencies and need an inverse transform
                FFT.Execute( fftwlib.FFT2D.Normalization.SQUARE_ROOT_OF_DIMENSIONS_PRODUCT );

            // DEBUG: Test we get back what we fed!
            // FFT.SwapInputOutput();
            // FFT.InputIsSpatial = false;
            // FFT.Execute( fftwlib.FFT2D.Normalization.SQUARE_ROOT_OF_DIMENSIONS_PRODUCT );

                // Retrieve results
                outputPanelSpatial.FillBitmap( ( int _X, int _Y, int _Width, int _Height ) =>
                    {
                        int	X = 256 * _X / _Width;
                        int	Y = 256 * _Y / _Height;
                        byte	R = (byte) (255 * Math.Min( 1.0f, Math.Abs( FFT.Output[2*(256*Y+X)+0] )));
                        byte	I = (byte) (255 * Math.Min( 1.0f, Math.Abs( FFT.Output[2*(256*Y+X)+1] )));
            // byte	R = (byte) (255 * Math.Min( 1.0f, 1.0e6 * Math.Abs( FFT.Output[2*(256*Y+X)+0] ) ));
            // byte	I = (byte) (255 * Math.Min( 1.0f, 1.0e6 * Math.Abs( FFT.Output[2*(256*Y+X)+1] ) ));

                        return 0xFF000000 | (uint) ((R << 16) | (I << 8));
                    } );

                //////////////////////////////////////////////////////////////////////////
                // Save the results
                System.IO.FileInfo		F = new System.IO.FileInfo( @".\Water0_256x256.complex" );
                System.IO.FileStream	S = F.Create();
                System.IO.BinaryWriter	Writer = new System.IO.BinaryWriter( S );

                for ( int Y=0; Y < 256; Y++ )
                    for ( int X=0; X < 256; X++ )
                    {
                        Writer.Write( FFT.Output[2*(256*Y+X)+0] );
//.........这里部分代码省略.........
开发者ID:Patapom,项目名称:GodComplex,代码行数:101,代码来源:Form1.cs

示例6: Main

        static void Main(string[] args)
        {
            string tempPath = System.Environment.GetEnvironmentVariable ("TEMP");
            if (tempPath == null) {
                tempPath = System.Environment.GetEnvironmentVariable ("TMP");
            }
            if (tempPath == null) {
                tempPath = "..\\..";
            }

            string machineName = String.Empty;
            string longKeyName = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
            string longValName = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";

            Exception exc = null;
            System.DateTime now = InicDateTime ();
            Object obj = null;
            string[] sL = null;
            Microsoft.Win32.RegistryKey rKey1 = null;
            Microsoft.Win32.RegistryKey rKey = null;
            Microsoft.Win32.RegistryKey rKey2 = null;

            System.IO.FileInfo fileInfo = new System.IO.FileInfo (tempPath + "\\resources12reg.txt");
            fileInfo.Create ().Close ();
            System.IO.StreamWriter outFile = fileInfo.AppendText ();
            System.Console.WriteLine (tempPath + "\\resources12reg.txt");

            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey (longKeyName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longKeyName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.CreateSubKey(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                now = System.DateTime.Now;
                /*<Resource>*/Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey (longKeyName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longKeyName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.DeleteSubKey(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + "");
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                now = System.DateTime.Now;
                /*<Resource>*/Microsoft.Win32.Registry.ClassesRoot.SetValue (longValName, "newData");
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longValName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.SetValue(String, Object)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + "");
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                obj = null;
                now = System.DateTime.Now;
                /*<Resource>*/obj = Microsoft.Win32.Registry.ClassesRoot.GetValue (longValName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longValName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.GetValue(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (obj));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                now = System.DateTime.Now;
                /*<Resource>*/Microsoft.Win32.Registry.ClassesRoot.DeleteValue (longValName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longValName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.DeleteValue(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Holodeck,代码行数:101,代码来源:TestApplication12.cs

示例7: Main

        static void Main(string[] args)
        {
            string tempPath = System.Environment.GetEnvironmentVariable ("TEMP");
            if (tempPath == null) {
                tempPath = System.Environment.GetEnvironmentVariable ("TMP");
            }
            if (tempPath == null) {
                tempPath = "..\\..";
            }

            string machineName = String.Empty;

            Exception exc = null;
            System.DateTime now = InicDateTime ();
            Object obj = null;
            string[] sL = null;
            Microsoft.Win32.RegistryKey rKey1 = null;
            Microsoft.Win32.RegistryKey rKey = null;
            Microsoft.Win32.RegistryKey rKey2 = null;

            System.IO.FileInfo fileInfo = new System.IO.FileInfo (tempPath + "\\resources2reg.txt");
            fileInfo.Create ().Close ();
            System.IO.StreamWriter outFile = fileInfo.AppendText ();
            System.Console.WriteLine (tempPath + "\\resources2reg.txt");

            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.ClassesRoot, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_CLASSES_ROOT");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.CurrentConfig, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_CURRENT_CONFIG");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.DynData, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_DYN_DATA");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.LocalMachine, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_LOCAL_MACHINE");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.PerformanceData, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_PERFORMACE_DATA");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Holodeck,代码行数:101,代码来源:TestApplication2.cs

示例8: MyApplicationData

        /// <summary>
        /// Connects to and opens a file for binary reading and writing
        /// If File doesn't exis
        /// </summary>
        /// <param name="sFile"></param>
        public MyApplicationData(string sFile, bool CreateFileIfNotExist)
        {
            System.IO.FileInfo FI = new System.IO.FileInfo(sFile);

            bool bExist = FI.Exists;

            if(bExist == false)
            {
                if(!CreateFileIfNotExist)
                {
                    if(bExist == false)
                    {
                        throw new Exception("Could not locate " + FI.Name);
                    }
                }
                else
                {
                    FI.Create();
                    FI = null;
                }
            }
            FileName = sFile;
            GetApplicationData();
        }
开发者ID:CarverLab,项目名称:Oyster,代码行数:29,代码来源:Globals.cs

示例9: client_DownloadDataCompleted

 private void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     if (e.Error == null && !e.Cancelled)
     {
         App.Current.DataCache.SaveData(userAudio.Url, e.Result);
         if (!string.IsNullOrEmpty(e.UserState.ToString()))
         {
             System.IO.FileInfo fi = new System.IO.FileInfo(e.UserState.ToString());
             if (fi.Exists)
             {
                 fi.Attributes = System.IO.FileAttributes.Normal;
                 fi.Delete();
             }
             else
             {
                 System.IO.FileStream fs = fi.Create();
                 fs.Write(e.Result, 0, (int)e.Result.LongLength);
                 fs.Flush();
                 if (fs != null)
                 {
                     fs.Close();
                     fs.Dispose();
                 }
             }
         }
     }
 }
开发者ID:OleksandrKulchytskyi,项目名称:VkManager,代码行数:27,代码来源:WindowAudio.xaml.cs

示例10: DumpBody

		/// <summary>
		/// Dumps the body of this entity into a file
		/// </summary>
		/// <param name="path">path of the destination folder</param>
		/// <param name="name">name of the file</param>
		/// <returns><see cref="System.IO.FileInfo" /> that represents the file where the body has been saved</returns>
        public System.IO.FileInfo DumpBody(System.String path, System.String name)
		{
		    System.IO.FileInfo file = null;
		    if (name != null)
		    {

		        name = System.IO.Path.GetFileName(name);
		        // Dump file contents
		        try
		        {
		            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path);
		            dir.Create();
		            try
		            {
		                file = new System.IO.FileInfo(System.IO.Path.Combine(path, name));
		            }
		            catch (System.ArgumentException exception)
		            {
		                file = null;
		                throw new Exception(
		                    System.String.Concat("Filename [", System.IO.Path.Combine(path, name),"] is not allowed by the filesystem"), exception);
		            }
		            if (dir.Exists)
		            {
		                if (dir.FullName.Equals(new System.IO.DirectoryInfo(file.Directory.FullName).FullName))
		                {
		                    if (!file.Exists)
		                    {
		                        System.IO.Stream stream;
		                        try
		                        {
		                            stream = file.Create();

		                        }
		                        catch (System.Exception e)
		                        {
		                            throw new Exception(System.String.Concat("Error creating file [", file.FullName, "]"), e);

		                        }
		                        try
		                        {
		                            this.DumpBody(stream);
		                        }
		                        catch (Exception)
		                        {
                                    throw new Exception(System.String.Concat("Error writting file [", file.FullName, "] to disk"));
		                        }
		                        stream.Close();
	
		                        // The file should be there
		                        file.Refresh();
		                        // Set file dates
		                        if (this.Header.ContentDispositionParameters.ContainsKey("creation-date"))
		                            file.CreationTime =
		                                MimeTools.parseDate(this.Header.ContentDispositionParameters["creation-date"]);
		                        if (this.Header.ContentDispositionParameters.ContainsKey("modification-date"))
		                            file.LastWriteTime =
		                                MimeTools.parseDate(this.Header.ContentDispositionParameters["modification-date"]);
		                        if (this.Header.ContentDispositionParameters.ContainsKey("read-date"))
		                            file.LastAccessTime =
		                                MimeTools.parseDate(this.Header.ContentDispositionParameters["read-date"]);

		                    }
		                    else
		                    {
		                        System.Console.WriteLine("File already exists, skipping.");
		                    }

		                }

		            }
		        }
		        catch (System.Exception)
		        {
                    if (file != null)
                    {
                        file.Refresh();
                        if (file.Exists)
                            file.Delete();
                    }
		            file = null;
		        }
		    }
		    return file;
		}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:91,代码来源:MimeMessage.cs

示例11: SaveSettings

        private void SaveSettings()
        {
            System.Xml.Linq.XElement x = new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("Settings"));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("HistoryCount"), nudHistory.Value));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("SlotCount"), nudSlots.Value));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("EmailAddress"), EmailAddress));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("UserName"), UserName));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("ServerAddress"), ServerAddress));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("ServerPassword"), Password));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("SMTPPort"), Port));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("EnableSSL"), enableSSL));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("SubjectLine"), SubjectLine));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("OpeningLine"), OpeningLine));
            x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("ClosingLine"), ClosingLine));

            System.IO.FileInfo f = new System.IO.FileInfo("settings.xml");
            if (f.Exists)
                f.Delete();
            var str = f.Create();
            var buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(x.ToString());
            str.Write(buffer, 0, buffer.Length);
            str.Close();
            str.Dispose();

            Properties.Settings.Default.HistoryCount = nudHistory.Value;
            Properties.Settings.Default.SlotCount = nudSlots.Value;
            Properties.Settings.Default.Save();
        }
开发者ID:mbaldini,项目名称:F10GenTool,代码行数:28,代码来源:Form1.cs

示例12: SavePlayerList

        private void SavePlayerList()
        {
            System.IO.FileInfo f = new System.IO.FileInfo("f10Players.xml");
            if (f.Exists)
                f.Delete();
            var str = f.Create();
            var buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(this.list.GetSerializedString());
            str.Write(buffer, 0, buffer.Length);
            str.Close();
            str.Dispose();

            Properties.Settings.Default.PlayerList = this.list.GetSerializedString();
            Properties.Settings.Default.Save();
        }
开发者ID:mbaldini,项目名称:F10GenTool,代码行数:14,代码来源:Form1.cs

示例13: SaveF10List

        private void SaveF10List()
        {
            Data_Classes.F10Entry f10 = new Data_Classes.F10Entry();
            f10.F10Date = monthCalendar1.SelectionStart.Date;
            List<string> pl = new List<string>();
            List<string> ml = new List<string>();
            foreach (Data_Classes.F10Player p in f10BindingSource)
            {
                pl.Add(p.NickName);
                if (p.MissedDate)
                    ml.Add(p.NickName);
            }
            f10.Players = pl.ToArray();
            f10.Missed = ml.ToArray();

            if (F10History.Count((x) => x.F10Date.Date == f10.F10Date.Date) > 0)
                F10History.RemoveAll((x) => x.F10Date.Date == f10.F10Date.Date);

            F10History.Add(f10);

            System.IO.FileInfo f = new System.IO.FileInfo("f10Info.xml");
            if (f.Exists)
                f.Delete();
            var str = f.Create();
            var buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(F10History.GetSerializedString());
            str.Write(buffer, 0, buffer.Length);
            str.Close();
            str.Dispose();

            Properties.Settings.Default.F10List = F10History.GetSerializedString();
            Properties.Settings.Default.Save();
        }
开发者ID:mbaldini,项目名称:F10GenTool,代码行数:32,代码来源:Form1.cs

示例14: Main

        static void Main(string[] args)
        {
            string tempPath = System.Environment.GetEnvironmentVariable ("TEMP");
            if (tempPath == null) {
                tempPath = System.Environment.GetEnvironmentVariable ("TMP");
            }
            if (tempPath == null) {
                tempPath = "..\\..";
            }

            Exception exc = null;
            System.DateTime now = System.DateTime.Now;
            System.Security.Cryptography.X509Certificates.X509Certificate xc = null;
            System.IO.StreamWriter sw = null;
            System.IO.StreamReader sr = null;
            System.IO.DirectoryInfo di = null;
            bool b = false;
            System.DateTime dt = InicDateTime ();
            string[] sL = null;
            System.IO.FileInfo[] fiL = null;
            System.IO.DirectoryInfo[] diL = null;
            System.IO.FileSystemInfo[] fsiL = null;
            System.IO.FileStream fs = null;
            System.IO.FileInfo fi = null;
            System.IAsyncResult asr = null;
            int i = 0;
            long l = 0;
            string s = null;
            System.IO.IsolatedStorage.IsolatedStorageFile isf = null;
            System.IO.IsolatedStorage.IsolatedStorageFileStream isfs = null;
            byte[] bL = null;
            System.Diagnostics.Process p = null;

            System.IO.FileInfo fileInfo = new System.IO.FileInfo (tempPath + "\\resources4file.txt");
            fileInfo.Create ().Close ();
            System.IO.StreamWriter outFile = fileInfo.AppendText ();
            System.Console.WriteLine (tempPath + "\\resources4file.txt");

            try {
                exc = null;
                xc = null;
                now = System.DateTime.Now;
                xc = System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile (tempPath + "\\dummyFile1.txt");
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + tempPath + "\\dummyFile1.txt");
                outFile.WriteLine ("Func: " + "System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (xc));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                xc = null;
                now = System.DateTime.Now;
                xc = System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromSignedFile (tempPath + "\\dummyFile2.txt");
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + tempPath + "\\dummyFile2.txt");
                outFile.WriteLine ("Func: " + "System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromSignedFile(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (xc));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            /*
            try {
            System.IO.BinaryWriter.Write ();
            System.IO.BinaryWriter.Seek ();
            System.IO.BinaryWriter.Flush ();
            System.IO.BinaryWriter.Close ();
            System.IO.BinaryWriter bw = new System.IO.BinaryWriter ();
            } catch (Exception e) {
            }

            try {
            System.IO.BufferedStream.WriteByte ();
            System.IO.BufferedStream.Write ();
            System.IO.BufferedStream.ReadByte ();
            System.IO.BufferedStream.Read ();
            System.IO.BufferedStream.SetLength ();
            System.IO.BufferedStream.Seek ();
            System.IO.BufferedStream.EndWrite ();
            System.IO.BufferedStream.BeginWrite ();
            System.IO.BufferedStream.EndRead ();
            System.IO.BufferedStream.BeginRead ();
            System.IO.BufferedStream.Flush ();
            System.IO.BufferedStream.Close ();
            System.IO.BufferedStream bs = new System.IO.BufferedStream ();
            } catch (Exception e) {
            }
            */
            try {
                exc = null;
                try {
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Holodeck,代码行数:101,代码来源:TestApplication4.cs


注:本文中的System.IO.FileInfo.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。