public static void INIT() { string path = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName; int i = path.IndexOf("MYLIVE"); path = path.Substring(0, i) + "MYLIVE\\"; root = path; data = root + "DATA"; test = root + "TEST"; outf = root + "OUT"; templ = root + "TEMPLATES"; _new = root + "_NEW"; _newd = _new + "\\DOGANDCAT"; _newf = _new + "\\FRIENDS"; _neww = _new + "\\WORKOUT"; _newb = _new + "\\BOOK"; _news = _new + "\\SPORT"; _newfood = _new + "\\FOOD"; datad = data + "\\PICTURES\\DOGANDCAT"; datab = data + "\\PICTURES\\BOOK"; dataf = data + "\\PICTURES\\FRIENDS"; dataw = data + "\\PICTURES\\WORKOUT"; datas = data + "\\PICTURES\\SPORT"; datafood = data + "\\PICTURES\\FOOD"; datat = data + "\\PICTURES\\TRAVEL"; imgProcessedFile = data + "\\parsed.txt"; refs.Add(new refItem() { _type = "DOGANDCAT", newPass = PATH._newd, destinationPass = PATH.datad, htmlPath = "" }); refs.Add(new refItem() { _type = "FRIENDS", newPass = PATH._newf, destinationPass = PATH.dataf, htmlPath = "" }); refs.Add(new refItem() { _type = "WORKOUT", newPass = PATH._neww, destinationPass = PATH.dataw, htmlPath = "" }); refs.Add(new refItem() { _type = "SPORT", newPass = PATH._news, destinationPass = PATH.datas, htmlPath = "" }); refs.Add(new refItem() { _type = "FOOD", newPass = PATH._newfood, destinationPass = PATH.datafood, htmlPath = "" }); refs.Add(new refItem() { _type = "BOOK", newPass = PATH._newb, destinationPass = PATH.datab, htmlPath = "" }); }
/*метод, загружающий доступные исполняумые * файлы из домашней директории проекта*/ 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); } }
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"); } }
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; }
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); } }
private static string GetMapName(string file) { var name = new FileInfo(file).Name; return name.Substring(0, name.IndexOf(".txt", StringComparison.OrdinalIgnoreCase)); }
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"); } }
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(); } }
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); } }
/// <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")); }
public static String GetTipoArquivo(String filename) { String shortName = new System.IO.FileInfo(filename).Name; return shortName.Substring(shortName.IndexOf("ACCC"), 7); }