// // GET: /Books/ public ActionResult Laws() { LoadKeys s1 = LoadKeys.Instance(); List <BookModel> items = LoadKeys.list; String Path = Server.MapPath("/Audio/Books/Laws"); String[] FileNames = Directory.GetFiles(Path); List <DocumentModel> list = new List <DocumentModel>(); foreach (var data in items) //iterate the file list { foreach (string path in FileNames) //iterate the file list { string x = path; // Find the last occurrence of N. int index1 = x.LastIndexOf('\\'); string fullname = x.Substring(index1 + 1); string shortname = fullname.Substring(0, fullname.Length - 4); if (shortname == data.Chapter) { list.Add(new DocumentModel(fullname, shortname, "\\Audio\\Books\\Laws\\" + fullname)); break; } } } ViewData["orderData"] = list; return(View()); }
public ActionResult Laws() { LoadKeys s1 = LoadKeys.Instance(); List <BookModel> items = LoadKeys.list; String Path = Server.MapPath("/Audio/Books/Laws"); String[] FileNames = Directory.GetFiles(Path); List <DocumentModel> list = new List <DocumentModel>(); foreach (var data in items) //iterate the file list { foreach (string path in FileNames) //iterate the file list { string x = path; // Find the last occurrence of N. int index1 = x.LastIndexOf('\\'); string fullname = x.Substring(index1 + 1); string shortname = fullname.Substring(0, fullname.Length - 4); if (shortname.ToUpper() == data.Chapter.ToUpper()) { list.Add(new DocumentModel(fullname, shortname, "\\Audio\\Books\\Laws\\" + fullname, "http://www.evolutionrevolutionoflove.com/Audio/Books/Laws/" + fullname)); break; } } } // comment out later // run as visual studio administor //convert all words to upper //foreach (string path in FileNames) //iterate the file list //{ // string x = path; // // Find the last occurrence of \. // int index1 = x.LastIndexOf('\\'); // string fullname = x.Substring(index1 + 1); // string shortname = fullname.Substring(0, fullname.Length - 4); // //string upperCase = UppercaseFirsts.ConvertFirst(shortname)+"1"+".mp3"; // // copy 1 back to // string upperCase = UppercaseFirsts.ConvertFirst(shortname) + ".mp3"; // upperCase = upperCase.Substring(0, upperCase.Length - 5) + ".mp3"; ; // if (System.IO.File.Exists(path)) // { // Microsoft.VisualBasic.FileIO.FileSystem.RenameFile(path, upperCase); // } //} //InsertRecords myInsertRecords = new InsertRecords(); //myInsertRecords.loadData(list); ViewData["orderData"] = list; return(View()); }