Program.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using RamDavisk.Ramfs;
  2. using System;
  3. using System.Diagnostics;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using WebDAVSharp.Server;
  7. using WebDAVSharp.Server.Stores;
  8. using WebDAVSharp.Server.Stores.Locks;
  9. namespace RamDavisk
  10. {
  11. internal static class Program
  12. {
  13. /// <summary>
  14. /// 应用程序的主入口点。
  15. /// </summary>
  16. [STAThread]
  17. private static void Main()
  18. {
  19. IWebDavStore store = new WebDavRamfsStore(new WebDavStoreItemLock());
  20. var svr = new WebDavServer(ref store);
  21. const string url = "http://*:2333/";
  22. svr.Start(url);
  23. Application.EnableVisualStyles();
  24. Application.SetCompatibleTextRenderingDefault(false);
  25. var mainForm = new Form
  26. {
  27. Text = $"RamDavisk run at {url}",
  28. Width = 360,
  29. Height = 120,
  30. };
  31. var linkLabel = new LinkLabel
  32. {
  33. Dock = DockStyle.Fill,
  34. TextAlign = ContentAlignment.MiddleCenter,
  35. Text = url
  36. };
  37. linkLabel.Click += delegate { Process.Start("explorer", @"\\localhost@2333\DavWWWRoot"); };
  38. mainForm.Controls.Add(linkLabel);
  39. Application.Run(mainForm);
  40. svr.Stop();
  41. }
  42. }
  43. }