// 需要注意的是:txtServerPath文件夹有匿名可写的权限。
// 可以自己定义新文件名字
if(txtFileName.Text.Trim() == "" || txtServerPath.Text.Trim() == "")
{
MessageBox.Show("请输入你要上载的文件名字!","错误:", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
/// 得到文件名,文件扩展名字,服务器路径
string fileNamePath = txtFileName.Text.Trim();
string uriString = txtServerPath.Text.Trim();
string fileName = fileNamePath.Substring(fileNamePath.LastIndexOf("\\") + 1);
string fileNameExt = fileName.Substring(fileName.LastIndexOf(".") + 1);
if(uriString.EndsWith("/") == false) uriString = uriString + "/";
// 可以自己定义新文件名字
if(txtFileName.Text.Trim() == "" || txtServerPath.Text.Trim() == "")
{
MessageBox.Show("请输入你要上载的文件名字!","错误:", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
/// 得到文件名,文件扩展名字,服务器路径
string fileNamePath = txtFileName.Text.Trim();
string uriString = txtServerPath.Text.Trim();
string fileName = fileNamePath.Substring(fileNamePath.LastIndexOf("\\") + 1);
string fileNameExt = fileName.Substring(fileName.LastIndexOf(".") + 1);
if(uriString.EndsWith("/") == false) uriString = uriString + "/";
解决方案 »
- streamwriter的问题
- “A share violation has occurred.”是什么错误?
- VS2008发布的程序,有的人能更新,有的人需要等几个小时才能更新
- 刚接触C#, 求助!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 请问,使用System.Web.Mail.MailMessage发送邮件对于body部分如何定制?急!
- Dns.GetHostAddresses的问题
- 错误在哪里?updatecommand影响0行
- 用什么方法可以采集这个地址?
- C#Json字符串转为对象,求大虾来赐教,急急急!!!
- 着急 TradingView Demo .... 在线等.
- asp.net + c#,一个cs文件一个dll,可以做到吗?
- 当所要选的内容不在comboBox1的下拉列表中时,在comboBox1中输入后,如何让它添加进去??谢谢
{
OpenFileDialog dlgOpenFile = new OpenFileDialog();
dlgOpenFile.InitialDirectory = @"C:\";
dlgOpenFile.ShowReadOnly = false;
dlgOpenFile.ReadOnlyChecked = true;
dlgOpenFile.Filter = "所有文件 (*.*)|*.*";
if(dlgOpenFile.ShowDialog() == DialogResult.OK)
{
if(dlgOpenFile.ReadOnlyChecked == true)
{
txtFileName.Text = dlgOpenFile.FileName.ToString();
}
}
} private void button1_Click(object sender, System.EventArgs e)
{
// 需要注意的是:txtServerPath文件夹有匿名可写的权限。
// 可以自己定义新文件名字
if(txtFileName.Text.Trim() == "" || txtServerPath.Text.Trim() == "")
{
MessageBox.Show("请输入你要上载的文件名字!","错误:", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
/// 得到文件名,文件扩展名字,服务器路径
string fileNamePath = txtFileName.Text.Trim();
string uriString = txtServerPath.Text.Trim();
string fileName = fileNamePath.Substring(fileNamePath.LastIndexOf("\\") + 1);
string fileNameExt = fileName.Substring(fileName.LastIndexOf(".") + 1);
if(uriString.EndsWith("/") == false) uriString = uriString + "/";
String name = Path.GetFileName(file);//文件名(包括扩展名)
String exten = Path.GetExtension(file);//扩展名