本文整理汇总了C#中System.IO.FileInfo.Substring方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.FileInfo.Substring方法的具体用法?C# System.IO.FileInfo.Substring怎么用?C# System.IO.FileInfo.Substring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了System.IO.FileInfo.Substring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadsave
public void loadsave()
{
myspacenamelist = new SpaceNameDictionary();
string[] files = System.IO.Directory.GetFiles(root, "*.❣");
for (int i = 0; i < files.Length; i++)
{
string filetext = System.IO.File.ReadAllText(files[i]);
string filename=new System.IO.FileInfo(files[i]).Name;
string head = filename.Substring(0, filename.Length - 2);
string body = filetext.Substring(filetext.IndexOf(head));
SpaceName sn = new SpaceName(head, body);
myspacenamelist.Add(sn);
}
}
示例2: AutoImport
public static int AutoImport( List<string> args )
{
string dir = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfRebuild\umdimage.dat.ex\";
string voicedir = @"d:\_svn\GraceNote\GraceNote\Voices\";
string[] files = System.IO.Directory.GetFiles( dir );
List<String> dbsToUp = new List<string>();
foreach ( var x in nonstopDict ) {
string nonstopFile = GetFromSubstring( files, x.Key );
string scriptFile = GetFromSubstring( files, x.Value );
string scriptFileFilename = new System.IO.FileInfo( scriptFile ).Name;
string databaseId = scriptFileFilename.Substring( 0, 4 );
string databaseFile = @"d:\_svn\GraceNote\GraceNote\DanganRonpaBestOfDB\DRBO" + databaseId;
dbsToUp.Add( "DRBO" + databaseId );
//continue;
LIN lin = new LIN( scriptFile );
Nonstop nonstop = new Nonstop( nonstopFile );
int lastScriptEntry = 0;
foreach ( var item in nonstop.items ) {
int stringId = item.data[(int)NonstopSingleStructure.StringID] + 1;
int correspondingTextEntry = stringId * 2;
int correspondingScriptEntry = correspondingTextEntry - 1;
if ( item.data[(int)NonstopSingleStructure.Type] == 0 ) {
lastScriptEntry = correspondingTextEntry;
}
// --- insert comment info ---
string comment = (string)SqliteUtil.SelectScalar(
"Data Source=" + databaseFile,
"SELECT comment FROM Text WHERE id = ?",
new object[] { correspondingTextEntry } );
bool weakpt = item.data[(int)NonstopSingleStructure.HasWeakPoint] > 0;
comment = ( comment == "" ? "" : comment + "\n\n" )
+ "Autogenerated Info:\n"
+ ( lastScriptEntry == 0 ? "Corresponds to file: " + scriptFileFilename : "" )
+ ( item.data[(int)NonstopSingleStructure.Type] == 0 ? "Normal Line\n" : "Background Noise\n" )
+ ( weakpt ? "Has a Weak Point\n" : "No Weakpoint\n" )
+ ( weakpt && ( item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF ) != 255 ? "Shot with Evidence Bullet: " + item.data[(int)NonstopSingleStructure.ShootWithEvidence] + "\n" : "" )
+ ( weakpt && ( item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF ) != 255 ? "Shot with Weak Point: " + item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] + "\n" : "" )
+ ( weakpt && ( item.data[(int)NonstopSingleStructure.ShootWithWeakpoint] & 0xFF ) == 255 && ( item.data[(int)NonstopSingleStructure.ShootWithEvidence] & 0xFF ) == 255 ? "Can't be shot\n" : "" )
+ ( item.data[(int)NonstopSingleStructure.Type] == 0 ? "" : "Appears around Entry #" + lastScriptEntry + "\n" )
+ ( item.data[(int)NonstopSingleStructure.Type] == 0 ? "Sprite: " + DanganUtil.CharacterIdToName( (byte)item.data[(int)NonstopSingleStructure.Character] ) + " " + item.data[(int)NonstopSingleStructure.Sprite] + "\n" : "" )
;
SqliteUtil.Update(
"Data Source=" + databaseFile,
"UPDATE Text SET comment = ?, updated = 1 WHERE id = ?",
new object[] { comment, correspondingTextEntry } );
// --- insert voice info ---
string script = (string)SqliteUtil.SelectScalar(
"Data Source=" + databaseFile,
"SELECT english FROM Text WHERE id = ?",
new object[] { correspondingScriptEntry } );
string voicename;
string voicefilecheck;
byte charid = (byte)item.data[(int)NonstopSingleStructure.Character];
if ( item.data[(int)NonstopSingleStructure.Type] == 0 ) {
while ( true ) {
string charac = DanganUtil.CharacterIdToName( charid );
if ( charac == "Naegi" ) { charac = "Neagi"; }
voicename = "[" + charac + "] " + item.data[(int)NonstopSingleStructure.Chapter] + " "
+ ( item.data[(int)NonstopSingleStructure.AudioSampleId] >> 8 ) + " " + ( item.data[(int)NonstopSingleStructure.AudioSampleId] & 0xFF ) + " 100";
voicefilecheck = voicedir + voicename + ".mp3";
if ( System.IO.File.Exists( voicefilecheck ) ) {
break;
}
charid = 0x12;
}
script += "<__END__>\n"
+ "<Voice: " + voicename + ">"
;
SqliteUtil.Update(
"Data Source=" + databaseFile,
"UPDATE Text SET english = ?, updated = 1 WHERE id = ?",
new object[] { script, correspondingScriptEntry } );
// update the header name thingy
string header = DanganUtil.CharacterIdToName( charid );
SqliteUtil.Update(
"Data Source=" + databaseFile,
"UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?",
new object[] { header, correspondingTextEntry } );
} else {
string header = "Background Noise";
SqliteUtil.Update(
"Data Source=" + databaseFile,
"UPDATE Text SET IdentifyString = ?, updated = 1 WHERE id = ?",
new object[] { header, correspondingTextEntry } );
}
}
}
System.IO.File.WriteAllLines(
//.........这里部分代码省略.........
示例3: Update
public void Update(string evt, params object[] data)
{
if (evt == LMSNotifications.ApplicationStart)
{
if (!isRun)
{
//mTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
//mTimer.Start();
string root = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName;
int index = root.IndexOf("\\Plugins");
root = root.Substring(0, index);
serverPath = root.Insert(index, "\\Data\\Index");
RebuildIndex(data[0] as ILmsService);
//var thread = new Thread(startMyTimer);
//thread.Start(((IWindsorContainer)data[0]).Resolve<ILmsService>());
//isRun = true;
}
}
if (evt == UserNotifications.UserCreate)
{
User user = (User)data[0];
Document document = new Document();
document.Add(new Field("Type", "User", Field.Store.YES, Field.Index.NO));
document.Add(new Field("UserID", user.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED));
document.Add(new Field("User", user.Name.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
AddToIndex(document);
}
if (evt == UserNotifications.UserEdit)
{
Update(UserNotifications.UserDelete, data[0]);
Update(UserNotifications.UserCreate, data[1]);
}
if (evt == UserNotifications.UserDelete)
{
User user = (User)data[0];
Term term = new Term("UserID", user.Id.ToString());
DeleteFromIndex(term);
}
if (evt == DisciplineNotifications.DisciplineCreate)
{
Discipline discipline = (Discipline)data[0];
Document document = new Document();
document.Add(new Field("Type", "Discipline", Field.Store.YES, Field.Index.NO));
document.Add(new Field("DisciplineID", discipline.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED));
document.Add(new Field("Owner", discipline.Owner, Field.Store.YES, Field.Index.NO));
document.Add(new Field("Discipline", discipline.Name.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
AddToIndex(document);
}
if (evt == DisciplineNotifications.DisciplineEdit)
{
Update(DisciplineNotifications.DisciplineDelete, data[0]);
Update(DisciplineNotifications.DisciplineCreate, data[1]);
}
if (evt == DisciplineNotifications.DisciplineDelete)
{
Discipline discipline = (Discipline)data[0];
Term term = new Term("DisciplineID", discipline.Id.ToString());
DeleteFromIndex(term);
}
if (evt == DisciplineNotifications.TopicCreate)
{
Topic topic = (Topic)data[0];
Document document = new Document();
document = new Document();
document.Add(new Field("Type", "Topic", Field.Store.YES, Field.Index.NO));
document.Add(new Field("TopicID", topic.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED));
document.Add(new Field("Topic", topic.Name.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
if (topic.CourseRef == null)
{
document.Add(new Field("CourseRef", "null", Field.Store.YES, Field.Index.NO));
}
else
{
document.Add(new Field("CourseRef", topic.CourseRef.ToString(), Field.Store.YES, Field.Index.NO));
}
AddToIndex(document);
}
if (evt == DisciplineNotifications.TopicEdit)
{
Update(DisciplineNotifications.TopicDelete, data[0]);
Update(DisciplineNotifications.TopicCreate, data[1]);
}
if (evt == DisciplineNotifications.TopicDelete)
//.........这里部分代码省略.........