本文整理汇总了C#中System.IO.FileInfo.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.IndexOf方法的具体用法?C# FileInfo.IndexOf怎么用?C# FileInfo.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.IndexOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAvailableAssemblies
/*метод, загружающий доступные исполняумые
* файлы из домашней директории проекта*/
void LoadAvailableAssemblies()
{
//название файла сборки текущего приложения
string except = new FileInfo(Application.ExecutablePath).Name;
//получаем название файла без расширения
except = except.Substring(0, except.IndexOf("."));
//получаем все *.exe файлы из домашней директории
string[] files = Directory.GetFiles(Application.StartupPath, "*.exe");
foreach (var file in files)
{
//получаем имя файла
string fileName = new FileInfo(file).Name;
/*если имя афйла не содержит имени исполняемого файла проекта, то оно добавляется в список*/
if (fileName.IndexOf(except) == -1)
AvailableAssemblies.Items.Add(fileName);
}
}
示例2: button2_Click
private void button2_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog op = new OpenFileDialog();
op.ShowDialog();
textBox3.Text = op.FileName;
//ProjectData.creteProject(textBox3.Text, dir);
string name = new FileInfo(op.FileName).Name;
name = name.Substring(0, name.IndexOf("."));
Directory.CreateDirectory(ProjectData.parent + dir + "/" + name);
ProjectData.creteFile(textBox3.Text, dir + "/" + name);
textBox1.Text = ProjectData.openTextFile(textBox3.Text, dir + "/" + name);
ProjectData.loadProject(dir, treeView1);
}
catch
{
MessageBox.Show("Upload a file");
}
}
示例3: GetHTML
public String GetHTML()
{
String email = Resource1.Email;
try
{
String shortName = new FileInfo(Filename).Name;
String typArq = shortName.Substring(shortName.IndexOf("ACCC"), 7);
String sTypArq = Utils.GetTypArq(typArq);
email = email.Replace(MAIL_NOMARQ, shortName);
email = email.Replace(MAIL_TIPARQ, typArq + " - " + sTypArq);
email = email.Replace(MAIL_TAMARQ, Tamanho.ToString("F2") + " MB");
email = email.Replace(MAIL_PRO, shortName.Contains("PRO.xml") ? "Sim" : "Não");
StringBuilder sb = new StringBuilder();
//header
sb.AppendLine(String.Format(MAIL_LINHA_HDR, "Cabeçalho"));
foreach (KeyValuePair<String, String> dado in Header)
{
String value = dado.Value;
if (!value.Equals(String.Empty))
{
sb.AppendLine(String.Format(MAIL_LINHADADO_HDR, dado.Key, dado.Value));
}
}
//body
sb.AppendLine(String.Format(MAIL_LINHA_HDR, "Dados"));
foreach (KeyValuePair<String, String> dado in Body)
{
sb.AppendLine(String.Format(MAIL_LINHADADO, dado.Key, dado.Value));
}
email = email.Replace(MAIL_DADOSARQ, sb.ToString());
}
catch (Exception ex)
{
if (Utils._logger != null)
Utils._logger.Error("Erro ao construir o body do email." + ex.Message);
}
return email;
}
示例4: LoadAvailebleAssemblies
public void LoadAvailebleAssemblies()
{
try
{
string except = new FileInfo(Application.ExecutablePath).Name;
except = except.Substring(0, except.IndexOf("."));
string[] files = Directory.GetFiles(Application.StartupPath, "*.exe");
foreach (var file in files)
{
string fileName = new FileInfo(file).Name;
if (fileName.IndexOf(except) == -1)
{
AvailebleAssemblies.Items.Add(fileName);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例5: GetMapName
private static string GetMapName(string file)
{
var name = new FileInfo(file).Name;
return name.Substring(0, name.IndexOf(".txt", StringComparison.OrdinalIgnoreCase));
}
示例6: recuperarMetadados
public Dictionary<string, Metadados> recuperarMetadados()
{
try
{
IFormatter formatter = new BinaryFormatter();
string[] arquivos = Directory.GetFiles(dirBanco + "\\" + dirBaseDados + "\\");
Dictionary<string, Metadados> dados = new Dictionary<string, Metadados>();
foreach (string arquivo in arquivos)
{
if (arquivo.EndsWith(".meta"))
{
Stream stream = new FileStream(arquivo, FileMode.Open, FileAccess.Read, FileShare.Read);
Metadados meta = (Metadados)formatter.Deserialize(stream);
string tabela = new FileInfo(arquivo).Name;
tabela = tabela.Remove(tabela.IndexOf('.'));
dados.Add(tabela, meta);
stream.Close();
}
}
return dados;
}
catch
{
throw new SGDBException("Tabela não existe");
}
}
示例7: ExtractTPose
static void ExtractTPose()
{
var selectedObjects = Selection.objects;
if (selectedObjects.Length > 0)
{
bool extracted = false;
foreach (var selectedObject in selectedObjects)
{
var assetPath = AssetDatabase.GetAssetPath(selectedObject);
if (!string.IsNullOrEmpty(assetPath))
{
// Get asset path directory
var assetDirectory = new FileInfo(assetPath).Directory.FullName + Path.DirectorySeparatorChar + "TPoses";
// Trim off the path at "Assets" to get the relative path to the assets directory
assetDirectory = assetDirectory.Substring(assetDirectory.IndexOf("Assets"));
var modelImporter = AssetImporter.GetAtPath(assetPath) as ModelImporter;
if( modelImporter != null )
{
var asset = UmaTPose.CreateInstance<UMA.UmaTPose>();
asset.ReadFromHumanDescription(modelImporter.humanDescription);
var name = selectedObject.name;
if (name.EndsWith("(Clone)"))
{
name = name.Substring(0, name.Length - 7);
asset.boneInfo[0].name = name;
asset.Serialize();
}
if (!Directory.Exists(assetDirectory))
Directory.CreateDirectory(assetDirectory);
try
{
AssetDatabase.CreateAsset(asset, assetDirectory + Path.DirectorySeparatorChar + name + "_TPose.asset");
}
catch (UnityException e)
{
Debug.Log(e.ToString());
}
extracted = true;
}
}
}
if (extracted)
{
AssetDatabase.SaveAssets();
return;
}
}
foreach (var animator in Transform.FindObjectsOfType(typeof(Animator)) as Animator[])
{
var asset = UmaTPose.CreateInstance<UmaTPose>();
asset.ReadFromTransform(animator);
var name = animator.name;
if (name.EndsWith("(Clone)"))
{
name = name.Substring(0, name.Length - 7);
asset.boneInfo[0].name = name;
asset.Serialize();
}
if (!Directory.Exists("Assets/UMA/UMA_Assets/TPoses"))
Directory.CreateDirectory("Assets/UMA/UMA_Assets/TPoses");
AssetDatabase.CreateAsset(asset, "Assets/UMA/UMA_Assets/TPoses/" + name + "_TPose.asset");
EditorUtility.SetDirty(asset);
AssetDatabase.SaveAssets();
}
}
示例8: BeforeUpdate
public override void BeforeUpdate()
{
if (_sqlBatCommand != null)
{
return;
}
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("APP", Settings.AutoUpdateSetting.Default.APP);
dictionary.Add("MD", Settings.AutoUpdateSetting.Default.Md);
dictionary.Add("TRD", Settings.AutoUpdateSetting.Default.Trd);
dictionary.Add("EXH", Settings.AutoUpdateSetting.Default.Exh);
_sqlBatCommand = new Dictionary<string, IList<UpdateSqlCommand>>();
foreach (KeyValuePair<string, string> keyValuePair in dictionary)
{
string dbDir = Path.Combine(Path.Combine(this.UpdateFolderName, this.DirectoryName), keyValuePair.Key);
string logDir = Path.Combine(dbDir, "log");
string sqlDir = Path.Combine(dbDir, "batsql");
if (!Directory.Exists(dbDir) || Directory.GetFiles(dbDir).Length == 0)
{
continue;
}
#region �ļ��д���
// ������־�ļ���
if (!Directory.Exists(logDir))
{
Directory.CreateDirectory(logDir);
}
// ����sql�������ļ���
if (!Directory.Exists(sqlDir))
{
Directory.CreateDirectory(sqlDir);
}
#endregion
#region ��ȡ���ݿ�����
string[] dbConnection = GetConnectionStrings(keyValuePair.Value);
if (dbConnection == null)
{
throw new Exception(string.Format("��ȡ{0}���ݿ������ַ���ʧ��", keyValuePair.Value));
}
#endregion
#region ����SQL�ļ�
//SQLִ�� ���Ⱥ�˳�� �����ȶ� ���ļ���װ�ļ��� ����
List<string> files = new List<string>(Directory.GetFiles(dbDir));
files.Sort();
List<UpdateSqlCommand> updateCommands = new List<UpdateSqlCommand>();
foreach (string file in files)
{
string fileName = new FileInfo(file).Name;
fileName = fileName.Substring(0, fileName.IndexOf('.')); // ȥ����չ��
// ������ִ�е�SQL�ļ�
string sqlFile = Path.Combine(sqlDir, string.Format("{0}.sql", fileName));
// log ��־�ļ�
string logFile = Path.Combine(logDir, string.Format("log_{0}.txt", fileName));
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendFormat("SPOOL {0}", logFile).AppendLine();
stringBuilder.AppendFormat("@{0}", file);
stringBuilder.Append(@"
SPOOL OFF
EXIT
EOF
");
WriteFile(sqlFile, stringBuilder.ToString());
#region ����ִ������
UpdateSqlCommand sqlCommand = new UpdateSqlCommand(file,
string.Format("SQLPLUS {0}/{1}@{2} @{3}",
dbConnection[1],
dbConnection[2],
dbConnection[0], sqlFile), logFile);
sqlCommand.SqlConnectionString = dbConnection[3];
sqlCommand.ProviderName = "Oracle.DataAccess.Client";
updateCommands.Add(sqlCommand);
#endregion
}
#endregion
_sqlBatCommand.Add(keyValuePair.Key, updateCommands);
}
}
示例9: Figure
/// <summary>
/// Creates a figure based on a file.
/// </summary>
/// <param name="fileName"> the file of the figure </param>
public Figure(String fileName)
{
fileString = fileName;
name = new FileInfo(fileName).Name;
name = name.Substring(0, name.IndexOf(".wrl"));
}
示例10: GetTipoArquivo
public static String GetTipoArquivo(String filename)
{
String shortName = new System.IO.FileInfo(filename).Name;
return shortName.Substring(shortName.IndexOf("ACCC"), 7);
}