-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcloudos.aspx.cs
More file actions
111 lines (98 loc) · 2.86 KB
/
Copy pathcloudos.aspx.cs
File metadata and controls
111 lines (98 loc) · 2.86 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Text;
using Ionic.Zip;
using System.Net;
public partial class cloudos : System.Web.UI.Page
{
static string fileLoc = "";
static string currentfile;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] == null)
{
Response.Redirect("signin.aspx");
}
else
{
fileLoc = "E:/cloudos/UserData/" + Session["UserName"].ToString() + "/Home/Documents/";
Literal1.Text = Session["UserName"].ToString();
}
}
[System.Web.Services.WebMethod]
public static void create(string fname)
{
string newfile;
if(!fname.EndsWith(".txt"))
newfile = fileLoc + fname + ".txt";
else
newfile = fileLoc + fname;
if (!File.Exists(newfile))
{
FileStream fs = File.Open(newfile, FileMode.CreateNew, FileAccess.ReadWrite);
currentfile = newfile;
}
}
[System.Web.Services.WebMethod(EnableSession=true)]
public static string open(string fname)
{
string name = fname;
if (!fname.EndsWith(".txt"))
name = fname + ".txt";
string path = "E:/cloudos/UserData/" + System.Web.HttpContext.Current.Session["UserName"].ToString() + "/";
string[] fpath = Directory.GetFiles(path, name, SearchOption.AllDirectories);
if (fpath.Length == 1)
{
if (File.Exists(fpath[0]))
{
string cntnt = File.ReadAllText(fpath[0]);
currentfile = fpath[0];
return cntnt;
}
else
{
return "fail";
}
}
else if (fpath.Length >= 1)
return "more";
else
return "fail";
}
[System.Web.Services.WebMethod]
public static string save(string cntn)
{
try
{
if (File.Exists(currentfile))
{
File.WriteAllText(currentfile, cntn);
return "success";
}
else
{
return "fail";
}
}
catch (Exception ex)
{
return "fail";
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Session.Abandon();
Page.ClientScript.RegisterStartupScript(this.GetType(),"Javascript", "block();", true);
}
}