我想使用以下代码从网站下载文件:
WebClient webClient = new WebClient();
webClient.DownloadFile("http://www.nseindia.com/content/historical/EQUITIES/2011/MAR/cm07MAR2011bhav.csv.zip", @"c:\myfile.txt");
Run Code Online (Sandbox Code Playgroud)
显示的例外是"禁止错误403"
这意味着找不到页面,但我可以使用java代码下载该文件,也可以直接从该网站下载.
如何使用C#代码下载?
char[] charArray = startno.ToCharArray();
//using this arry
//i want to cheque this
int i=0;
count = 0;
while (chenum [i] != "0")
{
count++;
i++;
}
string s = "0";
string zero = "0";
for (i = 1; i <= count; i++)
{
s = s + zero;
}
Run Code Online (Sandbox Code Playgroud)
你会帮我纠正这个代码吗...例如:(00001101)我需要添加这个没有1.因为我想将此值转换为int.if我转换为int否则将是(1101)+1否则将是(1102).在添加之后我想要答案(00001102).
public ArrayList ChequeACpayee(string Payee, DateTime Date)
{
ArrayList arr = new ArrayList();
try
{
con.Open();
SqlCommand cmd = new SqlCommand("ViewChequeforAcPayee", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p = new SqlParameter();
p = cmd.Parameters.AddWithValue("@PayeeName", Payee);
p = cmd.Parameters.AddWithValue("@Date", Date);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
ChequeInfo infoCheque = new ChequeInfo();
infoCheque.AcPayee = dr["AcPayee"].ToString();
arr.Add(infoCheque);
}
dr.Close();
con.Close();
}
catch (Exception e)
{
}
return arr;
}
ArrayList ArrAcpayee = ChequeAcPayee.ChequeACpayee (DDLPayee.SelectedItem.ToString(), BDPSelectDate.SelectedDate);
Run Code Online (Sandbox Code Playgroud)
如何从这个arraylist中获取单个值?该值必须转换为字符串.