Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string path = "C:\\Users\\Sindri\\Dropbox\\G21\\Sprint 6\\Munchbilder"; // Hvor bildene ligger på din disk
- List<string> fileNames = new List<string>();
- FileStream fs = new FileStream("SQLStatements.txt", FileMode.Create, FileAccess.Write);
- StreamWriter sw = new StreamWriter(fs);
- foreach (string file in Directory.EnumerateFiles(path, "*.png"))
- {
- int start = file.LastIndexOf('\\')+1;
- int end = (file.Length - start) - 4;
- string filename = file.Substring(start, end);
- Console.WriteLine(toSQL(filename));
- sw.WriteLine(toSQL(filename));
- }
- sw.Flush();
- sw.Close();
- Console.ReadKey(true);
- }
- public static string toSQL(string input)
- {
- string retval = "";
- string[] names = input.Split('-');
- if (names.Length > 1)
- {
- retval = "INSERT INTO paintings VALUES (NULL," + "'" + names[0] + "'" + ", " + "'" + names[1] + "'" + ",0);";
- }
- return retval;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement