私は初心者なので、これは私が見逃している本当に基本的なものだと確信しています。
csv
画像へのリンクを含むファイルを実行して、指定された保存ファイルの場所に画像を保存する簡単なプログラムがあります。
を含むセルを に解析していurl
ますList<string[]>
。
私がGetImage(@"http://www.example.com/picture.jpg", 1)
自分の機能を配置すると、本来のGetImage
機能が実行されます。ループを使用して変数を渡そうとすると、パスにstr[0]
不正な文字があるというエラーが表示されます。
私は a を使用しMessageBox
て違いが何であるかを教えてくれました。私が知る限り、関数に を渡すと、二重引用符が追加されます (つまり、 httpstr[0]
の代わりに "http://www.example.com" が表示されます)。1 つの文字列を送信するだけの場合は://www.example.comです。
私は何を間違っていますか?
private void button2_Click(object sender, EventArgs e)
{
string fileName = textBox1.Text;
folderBrowserDialog1.ShowDialog();
string saveLocation = folderBrowserDialog1.SelectedPath;
textBox2.Text = saveLocation;
List<string[]> file = parseCSV(fileName);
int count = 0;
foreach (string[] str in file)
{
if (count != 0)
{
GetImage(str[0], str[4]);
}
count++;
}
//GetImage(@"http://www.example.com/picture.jpg", "1");
}
private void GetImage(string url, string prodID)
{
string saveLocation = textBox2.Text + @"\";;
saveLocation += prodID + ".jpg";
WebClient webClt = new WebClient();
webClt.DownloadFile(url, saveLocation);
}