Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Nov 2007
Offline Last Active Aug 11 2015 06:41 AM

#5245694 Can someome please tell me why this crashes?

Posted by Enerjak on 11 August 2015 - 04:23 AM

var files = Directory.GetFiles("C:/Users/admin/Documents", "*.mp4");
for (int i=0; i<files.Length; ++i)
    files[i] = string.Format("{0}: {1}", i+1, files[i]);
File.WriteAllLines("video_filenames.txt", files);
Or, if you're feeling crazy:
File.WriteAllLines("video_filenames.txt", Directory.GetFiles("C:/Users/admin/Documents", "*.mp4").Select((x,i) => string.Format("{0}: {1}", i+1, x)));

Thanks, man. That helped a lot. I was going to use C++ but thought using C# would have been far easier to do so. I was right, just was making it complicated I guess.

#5245630 Can someome please tell me why this crashes?

Posted by Enerjak on 10 August 2015 - 08:02 PM

I want to clear some space from my hard drive. I have a few mp4s I downloaded from youtube and I just don't have time to watch them all. I want to delete them to make space on my hard drive but I don't want to lose them as I might not remember the title of a video of I want to go find it again. So I made this program to find all the files with .mp4 in a directory and write the file names to file so I can delete the .mp4s, thus freeing space in my computer. Problem is....the application crashes with this error: 




Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace FileData
    class Program
        static void Main(string[] args)
            string fileName = "video_filenames.txt";
            DirectoryInfo di = new DirectoryInfo("C:\\Users\\admin\\Documents");

            if (di != null)
                Console.Write("Directory exists");
                FileInfo[] fi = di.GetFiles("*.mp4");
                string str = "";
                if (fi != null)

                    if (File.Exists(fileName))
                        foreach (FileInfo file in fi)
                            str += file.FullName;
                    File.WriteAllText(fileName, str + "\n");

What should I do?

#5043969 drawing a 2D torus (basically a circle with a hole in it).

Posted by Enerjak on 17 March 2013 - 09:40 AM

thanks, I can always count on the fine people on this forum!