我有我的代碼張貼在表單中的JavaScript數組:ASP形式的操作文件(FileSystemObject的)
<form id="my_form" action="file:///C:/Users/John/Desktop/jquery/savetext.aspx" method="post" onsubmit="return prepare()">
<input type="text" id="file_name" name="file_name" rows="1" cols="20" />
<input type="hidden" name="seatsArray" />
<input type="submit" value="Save" />
</form>
<script type="text/javascript">
function prepare();
{
document.getElementById('seatsArray').value = seatsArray.join();
return true;
}
</script>
誰能幫我出我需要的savetext.aspx操作文件,因爲我的ASP.NET的知識是最小的(我習慣於PHP,但這需要是ASP.NET)。
我想我可以在越來越近的地方一條縫:
<%@ Page Language="C#" %>
<script runat="server">
using System;
using System.IO;
class Test
{
public static void Main()
{
string path = "file:///C:/Users/John/Desktop/jquery/txtfiles/" + request.form("file_name");
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine(request.form("seatsArray"));
sw.WriteLine("");
}
}
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
}
}
</script>
我在正確的軌道上?
非常感謝!
所以,你想要有人爲你做你的工作嗎?你必須更好地問。順便說一句,.asp不是ASP.NET。 – 2010-07-12 18:31:13
我只需要一些代碼來完成這個該死的事情。否則,我將不得不花費數週時間來學習如何預先做好。哦,我沒有意識到有什麼不同。這是ASP.NET我需要具體。 – IceDragon 2010-07-12 18:35:38
我的意思不是粗魯,但爲什麼你需要用你不熟練的語言來做某些事情,而不學習語言? – 2010-07-13 14:33:30