在网上看到很多asp.net的类,都是用c#写的.如:
public string Extension
{
get
{
if(extension!="") return extension;
return "txt";
}
set
{
extension=value;
}
}public string PathToName(string path)
{
int pos=path.LastIndexOf("\\");
return path.Substring(pos+1);
}public string Upload()
{
if(PostedFile!=null)
{
try{
string fileName=PathToName(PostedFile.FileName);
if(!fileName.EndsWith(Extension)) return "You must select "+Extension+" file!";
if(PostedFile.ContentLength>FileLength) return "File too big!";
PostedFile.SaveAs(SavePath+fileName);
return "Upload File Successfully!";
}
catch(System.Exception exc)
{return exc.Message;}
}
return "Please select a file to upload!";
}
}
}请问以上的类文件可以用vb来写吗?功能是不是一样的呢?谢谢.
public string Extension
{
get
{
if(extension!="") return extension;
return "txt";
}
set
{
extension=value;
}
}public string PathToName(string path)
{
int pos=path.LastIndexOf("\\");
return path.Substring(pos+1);
}public string Upload()
{
if(PostedFile!=null)
{
try{
string fileName=PathToName(PostedFile.FileName);
if(!fileName.EndsWith(Extension)) return "You must select "+Extension+" file!";
if(PostedFile.ContentLength>FileLength) return "File too big!";
PostedFile.SaveAs(SavePath+fileName);
return "Upload File Successfully!";
}
catch(System.Exception exc)
{return exc.Message;}
}
return "Please select a file to upload!";
}
}
}请问以上的类文件可以用vb来写吗?功能是不是一样的呢?谢谢.
解决方案 »
- javascript 如何把网页(html)转成图片文件 或 用C#将html字符串生成网页后转化为图片
- 下拉列表如何做成数据库后台控制的
- 有人用C#封装过大华DVR的SDK吗?
- 遇到难题了,绑定两个指定了父子关系的表到datagrid(两个Datagrid嵌套),现在父表有些记录字表没有相对应的记录
- DataGrid问题
- 新手拜地求救:editor.jsp的按钮栏不见了呢?最高100分了
- 为什么我的水晶报表显示的值都是以.00结尾的呢?
- 昨天发了一个贴。。引来大家发粪。。。那大家公布一下你们自己的DbHelperSQL。,发来,大家一起起学习习,改进一下。。。
- 百度云推送 ISO 推送自定义的键值对 custom_content
- 关于.net调试,怎么设置断点进行调试......
- 值的传递问题
- 求助 sql语句,谢谢
在.net语言中都能调用.
Public Property Extension() As String
Get
If extension <> "" Then
Return extension
End If
Return "txt"
End Get
Set
extension = value
End Set
End Property
Public Function PathToName(path As String) As String
Dim pos As Integer = path.LastIndexOf("\")
Return path.Substring((pos + 1))
End Function 'PathToName
Public Function Upload() As String
If Not (PostedFile Is Nothing) Then
Try
Dim fileName As String = PathToName(PostedFile.FileName)
If Not fileName.EndsWith(Extension) Then
Return "You must select " + Extension + " file!"
End If
If PostedFile.ContentLength > FileLength Then
Return "File too big!"
End If
PostedFile.SaveAs((SavePath + fileName))
Return "Upload File Successfully!"
Catch exc As System.Exception
Return exc.Message
End Try
End If
Return "Please select a file to upload!"
End Function 'Upload
'
'ToDo: Error processing original source shown below
'
'
'-^--- expression expected
'
'ToDo: Error processing original source shown below
'
'
'-^--- expression expected