-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom_File.cs
More file actions
30 lines (26 loc) · 807 Bytes
/
Random_File.cs
File metadata and controls
30 lines (26 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.IO;
using System.Linq;
namespace Random_File
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process.Start(getRandomFile(@"F:\other\torrent"));
}
private static string getRandomFile(string path)
{
try
{
var extensions = new string[] { ".torrent" };
var di = new DirectoryInfo(path);
return (di.GetFiles("*.*")
.Where(f => extensions.Contains(f.Extension.ToLower()))
.OrderBy(f => Guid.NewGuid())
.First()).FullName;
}
catch { return ""; }
}
}
}