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


C# IO.FileInfo类代码示例

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


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

示例1: runGame

 public void runGame()
 {
     //throw new Exception("LOGGING IS OFF!");
     base_dir = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Directory.FullName;
     AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
     var os = System.Environment.OSVersion;
     if (os.Version.Major > 5)
     {
         AppDomain.CurrentDomain.FirstChanceException += new EventHandler<System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs>(CurrentDomain_FirstChanceException);
     }
     try
     {
         var ass = System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes("GnomoriaModded.dll"));
         var ep = ass.EntryPoint;
         //var inst = ass.GetType("Game.GnomanEmpire").GetProperty("Instance").GetGetMethod().Invoke(null, new object[] { });
         //var obj = ass.CreateInstance(ep.Name);
         ep.Invoke(null, new object[] { new String[] { "-noassemblyresolve", "-noassemblyloading" } });
         return;
     }
     catch (Exception err)
     {
         CustomErrorHandler(err);
     }
 }
开发者ID:Rychard,项目名称:Faark.Gnomoria.Modding,代码行数:25,代码来源:GameLauncher.cs

示例2: cc_Click

        private void cc_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog d = new Microsoft.Win32.OpenFileDialog();
            d.Filter = "JPEG Image (*.JPG)|*.JPG";
               bool? result =  d.ShowDialog(this);
               if (result == true)
               {
               System.IO.FileInfo fi = new System.IO.FileInfo(d.FileName);
               //fi.CopyTo("..\\..\\Resources\\"+fi.Name,true);
               XmlDataProvider xdp = this.Resources["BookData"] as XmlDataProvider;
               System.Xml.XmlElement xe = (System.Xml.XmlElement)(e.Source as System.Windows.Controls.ContentControl).Content;
               if (xe["Image"] != null)
               {
                   xe["Image"].InnerText = fi.FullName;
                   //System.Xml.XmlTextWriter xr = new System.Xml.XmlTextWriter(new System.IO.FileStream(@"C:\a.txt", System.IO.FileMode.OpenOrCreate), Encoding.Unicode);
                   //xe.WriteTo(xr);
                   //xr.Close();

               }
               else
               {
                   System.Xml.XPath.XPathNavigator navigator = xe.CreateNavigator();
                   navigator.AppendChildElement(null, "Image", null, fi.FullName);
                   this.listBox.Items.Refresh();
               }
               }
        }
开发者ID:powernick,项目名称:CodeLib,代码行数:27,代码来源:MainWindow.xaml.cs

示例3: init

        public void init(Outlook.Attachment attach)
        {
            attachment = attach;
                System.IO.FileInfo fi = new System.IO.FileInfo(attachment.FileName);
                lNom.Text = "Nom : " + fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length);
                lType.Text = "Type : " + fi.Extension.ToString();
                lTaille.Text = "Taille : " + attachment.Size + " o";

                IDictionary<string, string> parameters = new Dictionary<string, string>();
                parameters[SessionParameter.BindingType] = BindingType.AtomPub;

                XmlNode rootNode = Config1.xmlRootNode();

                parameters[SessionParameter.AtomPubUrl] = rootNode.ChildNodes.Item(0).InnerText + "atom/cmis";
                parameters[SessionParameter.User] = rootNode.ChildNodes.Item(1).InnerText;
                parameters[SessionParameter.Password] = rootNode.ChildNodes.Item(2).InnerText;

                SessionFactory factory = SessionFactory.NewInstance();
                ISession session = factory.GetRepositories(parameters)[0].CreateSession();

                // construction de l'arborescence
                string id = null;
                IItemEnumerable<IQueryResult> qr = session.Query("SELECT * from cmis:folder where cmis:name = 'Default domain'", false);

                foreach (IQueryResult hit in qr) { id = hit["cmis:objectId"].FirstValue.ToString(); }
                IFolder doc = session.GetObject(id) as IFolder;

                TreeNode root = treeView.Nodes.Add(doc.Id, doc.Name);
                AddVirtualNode(root);
        }
开发者ID:ldoguin,项目名称:NuxeoOutlookAddin,代码行数:30,代码来源:NuxeoAttachList.cs

示例4: GetCurrentPageName

 internal static string GetCurrentPageName()
 {
     string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
     System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
     string sRet = oInfo.Name;
     return sRet;
 }
开发者ID:IndiansIncredible,项目名称:.NetIDS,代码行数:7,代码来源:Misc.cs

示例5: LoadPicture

        void LoadPicture()
        {
            this.OpenFile.Filter = "Images | *.jpg; *.png; *.jpeg";

            DialogResult result = this.OpenFile.ShowDialog();

            if ( result == DialogResult.OK )
            {
                string src = this.OpenFile.FileName;

                System.IO.FileInfo info = new System.IO.FileInfo( src );

                if ( ( info.Length / 1048576 ) < 1.5 )
                {
                    this.ptbPicture.Load( src );
                    this.lblSource.Text = src;
                    this._source = src;
                    this.btnCambiar.Enabled = true;
                    this.btnSalir.Enabled = true;
                }
                else
                {
                    MetroMessageBox.Show( this, "El Tamaño maximo para una imagen es de 1.5MB.", "LA imagen a superado el tamaño Maximo", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                }
            }
        }
开发者ID:SIDET2015,项目名称:LawraDesktop,代码行数:26,代码来源:mdl_ChangePicture.cs

示例6: 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

示例7: Log4NetProvider

        public Log4NetProvider()
        {
            GlobalContext.Properties["appname"] = "TutorGroup.Api";

            try
            {
                var codeBaseUri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
                var fileInfo = new System.IO.FileInfo(codeBaseUri.AbsolutePath);
                if (fileInfo.DirectoryName != null)
                {
                    var newConfigFilePath = System.IO.Path.Combine(fileInfo.DirectoryName, "ConfigurationFiles", "Logging/log4net/log4net.config");

                    if (System.IO.File.Exists(newConfigFilePath))
                    {
                        log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(newConfigFilePath));
                    }
                    else
                    {
                        throw new Exception("Log4net config file missing Error:");
                    }
                }
                else
                {
                    throw new Exception("Log4net config file missing Error:");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Log4net Initialize Error:" + ex.Message, ex);
            }

            GetLogger(DEFAULT_LOGGER);
        }
开发者ID:pin0513,项目名称:hip.infras,代码行数:33,代码来源:Log4NetProvider.cs

示例8: Application_Start

        protected void Application_Start()
        {
            string configFileName = Server.MapPath("~/log.log4net");
            System.IO.FileInfo f = new System.IO.FileInfo(configFileName);
            LogHelper.LogHelper.SetConfig(f, "");
            LogHelper.LogHelper.Info("App Start");

            SqlHelper.SetConnString(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            System.Data.Entity.Database.SetInitializer<OUDAL.Context>(null);
            Application["Login"] = System.Configuration.ConfigurationManager.AppSettings["Login"];
            RootPath = System.Configuration.ConfigurationManager.AppSettings["path"];

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            try
            {
                ClientBLL.AutoTransfer();
            }
            catch (Exception e)
            {

            }
            BundleMobileConfig.RegisterBundles(BundleTable.Bundles);

            //RealEstateCRM.Web.BLL.SynchronismWorkflow.SynchronishJob.Schedule();
        }
开发者ID:huaminglee,项目名称:RealEstateCRM,代码行数:30,代码来源:Global.asax.cs

示例9: BrowseButton_Click

 private void BrowseButton_Click(object sender, EventArgs e)
 {
     var path = "";
     GameApplicationOpenFileDialog.DefaultExt = ".exe";
     if (!string.IsNullOrEmpty(GameApplicationLocationTextBox.Text))
     {
         var fi = new System.IO.FileInfo(GameApplicationLocationTextBox.Text);
         if (string.IsNullOrEmpty(path)) path = fi.Directory.FullName;
         GameApplicationOpenFileDialog.FileName = fi.Name;
     }
     GameApplicationOpenFileDialog.Filter = Helper.GetFileDescription(".exe") + " (*.exe)|*.exe|All files (*.*)|*.*";
     GameApplicationOpenFileDialog.FilterIndex = 1;
     GameApplicationOpenFileDialog.RestoreDirectory = true;
     if (string.IsNullOrEmpty(path)) path = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
     GameApplicationOpenFileDialog.InitialDirectory = path;
     GameApplicationOpenFileDialog.Title = "Browse for Executable";
     var result = GameApplicationOpenFileDialog.ShowDialog();
     if (result == System.Windows.Forms.DialogResult.OK)
     {
         // Don't allow to add windows folder.
         var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows);
         if (GameApplicationOpenFileDialog.FileName.StartsWith(winFolder))
         {
             MessageBoxForm.Show("Windows folders are not allowed.", "Windows Folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             GameApplicationLocationTextBox.Text = GameApplicationOpenFileDialog.FileName;
             ProcessExecutable(GameApplicationOpenFileDialog.FileName);
         }
     }
 }
开发者ID:jeppeter,项目名称:x360ce,代码行数:32,代码来源:GamesControl.cs

示例10: Application_Start

 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     System.IO.FileInfo configFile = new System.IO.FileInfo(System.AppDomain.CurrentDomain.BaseDirectory + "\\web.config");
     log4net.Config.XmlConfigurator.Configure(configFile);
     CharityPlatform.Data.AppHelper.Init();
 }
开发者ID:mikerossconsulting,项目名称:CharityPlatform,代码行数:7,代码来源:Global.asax.cs

示例11: itemSelectedBuild

        protected void itemSelectedBuild(object sender, EventArgs e)
        {
            try
            {
                System.String filename = "myFile.txt";

                // set the http content type to "APPLICATION/OCTET-STREAM
                Response.ContentType = "APPLICATION/OCTET-STREAM";

                // initialize the http content-disposition header to
                // indicate a file attachment with the default filename
                // "myFile.txt"
                System.String disHeader = "Attachment; Filename=\"" + filename +
                   "\"";
                Response.AppendHeader("Content-Disposition", disHeader);

                // transfer the file byte-by-byte to the response object
                System.IO.FileInfo fileToDownload = new
                   System.IO.FileInfo("C:\\downloadJSP\\DownloadConv\\myFile.txt");
                Response.Flush();
                Response.WriteFile(fileToDownload.FullName);
            }
            catch (System.Exception exc)
            // file IO errors
            {
            }
        }
开发者ID:GehteuchNixan,项目名称:HODOR,代码行数:27,代码来源:Produkte.aspx.cs

示例12: ShowAddPackageDialog

        public static void ShowAddPackageDialog(string selectedFileName, string projectGuid = null)
        {
            Paket.Dependencies dependenciesFile = null;

            try
            {
                dependenciesFile = Paket.Dependencies.Locate(selectedFileName);
            }
            catch (Exception)
            {
                var dir = new System.IO.FileInfo(SolutionExplorerExtensions.GetSolutionFileName()).Directory.FullName;
                Dependencies.Init(dir);
                dependenciesFile = Paket.Dependencies.Locate(selectedFileName);
            }

            var secondWindow = new AddPackage();

            //Create observable paket trace
            var paketTraceObs = Observable.Create<Logging.Trace>(observer =>
            {
                [email protected](x => observer.OnNext(x));
                return Disposable.Create(() =>
                {
                   
                });
               
            });

            Action<NugetResult> addPackageToDependencies = result =>
            {
                if (projectGuid != null)
                {
                    var guid = Guid.Parse(projectGuid);
                    SolutionExplorerExtensions.UnloadProject(guid);
                    dependenciesFile.AddToProject(Microsoft.FSharp.Core.FSharpOption<string>.None, result.PackageName, "", false, false, false, false, selectedFileName, true, SemVerUpdateMode.NoRestriction);
                    SolutionExplorerExtensions.ReloadProject(guid);
                }
                else
                    dependenciesFile.Add(Microsoft.FSharp.Core.FSharpOption<string>.None, result.PackageName, "", false, false, false, false, false, true, SemVerUpdateMode.NoRestriction);
            };

            Func<string, IObservable<string>> searchNuGet = 
                searchText => Observable.Create<string>(obs =>
                {
                    var disposable = new CancellationDisposable();

                    dependenciesFile
                        .SearchPackagesByName(
                            searchText,
                            FSharpOption<CancellationToken>.Some(disposable.Token),
                            FSharpOption<int>.None)
                        .Subscribe(obs);

                    return disposable;
                });
          
            //TODO: Use interfaces?
            secondWindow.ViewModel = new AddPackageViewModel(searchNuGet, addPackageToDependencies, paketTraceObs);
            secondWindow.ShowDialog();
        }
开发者ID:freeman,项目名称:Paket.VisualStudio,代码行数:60,代码来源:AddPackageProcess.cs

示例13: CreateDatabase

        internal static void CreateDatabase(string DbFile)
        {
            string path = new System.IO.FileInfo(DbFile).DirectoryName;
            if (!System.IO.Directory.Exists(path))
                System.IO.Directory.CreateDirectory(path);

            SQLiteConnection.CreateFile(DbFile);

            using(SQLiteConnection conn = new SQLiteConnection(@"Data Source={0};Version=3;".FormatStr(DbFile))){
                conn.Open();
                foreach (Match match in Regex.Matches(Resources.Files.CreateDatabase_sql, @"(.*?)(([\s]+GO[\s]*)|$)", RegexOptions.Singleline | RegexOptions.IgnoreCase))
                {
                    string sql = match.Value.Trim();
                    if (sql.ToUpper().EndsWith("GO"))
                        sql = sql.Substring(0, sql.Length - 2).Trim();
                    if (sql.Length == 0)
                        continue;
                    using (SQLiteCommand cmd = new SQLiteCommand(sql, conn))
                    {
                        cmd.ExecuteNonQuery();
                    }
                }
                using(SQLiteCommand cmd = new SQLiteCommand("INSERT INTO [version](databaseversion) VALUES ({0})".FormatStr(Globals.DB_VERSION), conn))
                {
                    cmd.ExecuteNonQuery();
                }
                conn.Close();
            }

            DbHelper.DbFile = DbFile;
        }
开发者ID:revenz,项目名称:NextPvrWebConsole,代码行数:31,代码来源:DbHelper.cs

示例14: Window_Loaded

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //read config
            string PathDB = Logs.getPath() + "\\DB\\quran.db";
            System.IO.FileInfo ConFile = new System.IO.FileInfo(PathDB);
            if (!ConFile.Exists)
            {
                MessageBox.Show("Database not found.");
                Application.Current.Shutdown();

            }
            string ConStr = string.Format("Data Source={0};Version=3;", ConFile.FullName);
            BLL.quran_data.Conn = ConStr;

            //string ConStr = ConfigurationManager.ConnectionStrings["quran_context"].ConnectionString;
            //UrlRecitation = ConfigurationManager.AppSettings["UrlRecitation"];

            //player events
            QuranPlayer.MediaFailed += media_MediaFailed;
            QuranPlayer.MediaEnded += QuranPlayer_MediaEnded;

            //button events
            StopBtn.Click += StopBtn_Click;
            PlayBtn.Click += PlayBtn_Click;
            NextBtn.Click += NextBtn_Click;
            PrevBtn.Click += PrevBtn_Click;
            BookmarkBtn.Click += BookmarkBtn_Click;
            //QFE.WPF.Tools.CacheManager<string> Cache = new Tools.CacheManager<string>();
            //Cache["hosni"] = "gendut";
            //MessageBox.Show(Cache["hosni"]);

            InitQuran();

            //Init speech recognizer
            manualResetEvent = new ManualResetEvent(false);

            ListenToBoss();

            /*
            //real sense start
            cam = Camera.Create(); //autodiscovers your sdk (perceptual or realsense)

            //cam.Face.Visible += Face_Visible;
            //cam.Face.NotVisible += Face_NotVisible;
            cam.Gestures.SwipeLeft += Gestures_SwipeLeft;
            cam.Gestures.SwipeRight += Gestures_SwipeRight;
            //cam.Gestures.SwipeUp += Gestures_SwipeUp;
            //cam.Gestures.SwipeDown += Gestures_SwipeDown;
            cam.RightHand.Moved += RightHand_Moved;
            cam.LeftHand.Moved += LeftHand_Moved;
            cam.Start();


            //timer for human detection
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += dispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, CurrentState.config.ShutdownTime, 0);
            dispatcherTimer.Start();
            */
        }
开发者ID:Gravicode,项目名称:QFE,代码行数:60,代码来源:MainWindow.xaml.cs

示例15: addLog

 public static void addLog(string s)
 {
     System.Diagnostics.Debug.WriteLine(s);
     if (bDoLogging)
     {
         try
         {
             if (System.IO.File.Exists(LogFilename))
             {
                 System.IO.FileInfo fi = new System.IO.FileInfo(LogFilename);
                 if (fi.Length > maxFileSize)
                 {
                     //create backup file
                     System.IO.File.Copy(LogFilename, LogFilename + "bak", true);
                     System.IO.File.Delete(LogFilename);
                 }
             }
             System.IO.StreamWriter sw = new System.IO.StreamWriter(LogFilename, true);
             sw.WriteLine(DateTime.Now.ToShortDateString()+ " " + DateTime.Now.ToShortTimeString() + "\t" + s);
             sw.Flush();
             sw.Close();
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine("Exception in addLog FileWrite: " + ex.Message);
         }
     }
 }
开发者ID:hjgode,项目名称:mail_grabber,代码行数:28,代码来源:helpers.cs


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