温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:文件在线管理系统0.30源码
当前文件:
FileManager/WebSite/Manage/Notepad.aspx.cs,打开代码结构图
FileManager/WebSite/Manage/Notepad.aspx.cs,打开代码结构图1using System; 2
using System.IO; 3
using ptw.FileManager.Web.Processor; 4
5
public partial class Manage_Notepad : System.Web.UI.Page 6
{ 7
protected void Page_Load(object sender, EventArgs e) 8
{ 9
if (!IsPostBack) 10
{ 11
string filePath = Request.QueryString["objfile"]; 12
string folderPath = Request.QueryString["objfolder"]; 13
14
if (string.IsNullOrEmpty(folderPath)) 15
{ 16
if (File.Exists(filePath)) 17
{ 18
string fileContent; 19
string getEncode; 20
21
new FileManagerProcessor().ReadTextFile(filePath, out fileContent, out getEncode); 22
23
lblNew.Text = "false"; 24
txtFilePath.Text = filePath; 25
txtFileContent.Text = fileContent; 26
ddlEncode.SelectedValue = getEncode; 27
} 28
else 29
{ 30
lblMsg.Text = "<script type=\"text/javascript\">alert(\"没有找到文件\");</script>"; 31
} 32
} 33
else 34
{ 35
lblNew.Text = "true"; 36
txtFilePath.Text = folderPath + "\\newText.txt"; 37
txtFilePath.ReadOnly = false; 38
txtFileContent.Text = "在此输入文本内容"; 39
} 40
} 41
42
btnSave.Click += new EventHandler(OnSaveFile); 43
} 44
45
/// <summary> 46
/// 保存文件 47
/// </summary> 48
protected void OnSaveFile(object sender, EventArgs e) 49
{ 50
string filePath = txtFilePath.Text; 51
string fileContent = txtFileContent.Text; 52
string fileEncode = ddlEncode.SelectedValue; 53
bool fileNew = Convert.ToBoolean(lblNew.Text); 54
55
if (fileNew) 56
{ 57
if (File.Exists(filePath)) 58
{ 59
lblMsg.Text = "<script type=\"text/javascript\">alert(\"新建的文本文档名称目录下已存在\");</script>"; 60
return; 61
} 62
} 63
64
lblMsg.Text = new FileManagerProcessor().SaveTextFile(filePath, fileContent, fileEncode); 65
} 66
}





}
}