本文整理汇总了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);
}
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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 );
}
}
}
示例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;
}
}
示例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);
}
示例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();
}
示例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);
}
}
}
示例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();
}
示例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
{
}
}
示例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();
}
示例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;
}
示例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();
*/
}
示例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);
}
}
}