我制做了以下一个c#组件,调用时传递英文路径和文件名,如d:\test.txt 都返回正常的。 但如传递中文路径,如d:\测试.txt或d:\\测试.txt 则显示, 非法的路径或文件名。 请各位大虾帮忙!!!using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;namespace TestCOM
{
public class Class1
{
public string Hello(string name,out string ls_msg)
{
ls_msg = ""; try
{ FileStream myOutInFile = new FileStream(name, FileMode.Create); myOutInFile.Close();
myOutInFile.Dispose();
ls_msg = "OK"; return "1";
} catch (Exception de)
{
ls_msg = de.Message + de.StackTrace; return "-1";
}
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;namespace TestCOM
{
public class Class1
{
public string Hello(string name,out string ls_msg)
{
ls_msg = ""; try
{ FileStream myOutInFile = new FileStream(name, FileMode.Create); myOutInFile.Close();
myOutInFile.Dispose();
ls_msg = "OK"; return "1";
} catch (Exception de)
{
ls_msg = de.Message + de.StackTrace; return "-1";
}
}
}
}
解决方案 »
- switch与Dictionary哪个效率更高
- 关于 ArrayList 的问题,为什么第个组合都是全部的数据?
- 在线等了,如何加入一个输入框(类似于inputbox的东西)
- C#中是实现鼠标左键点击滑动选中控件变色功能
- WCF netTcpBinding如何实现异步?
- 鼠标 进入datagridview的某个单元格/列时,显示为手形
- ado.net 读取*.db 文件问题
- 自定义按件中在脚本函数中赋值问题!
- WEB 中更新ACCESS文件出错!有详细的IIS中文件操作权限设置吗?
- 请问如何实现windows XP中的那种很酷的按钮效果?
- 请教SerialPort问题 为什么逐行调试时可以取到数据,却在自动编译时没有取到数据哪?
- 在线等待 如何相应onload事件
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Runtime.InteropServices;
using System.IO; namespace MakeComponent
{
public partial class Component1 : Component
{
public Component1()
{
InitializeComponent();
} public Component1(IContainer container)
{
container.Add(this); InitializeComponent();
}
public string Hello(string name, out string ls_msg)
{
ls_msg = " "; try
{ FileStream myOutInFile = new FileStream(name, FileMode.Create); myOutInFile.Close();
myOutInFile.Dispose(); ls_msg = "OK "; return "1 ";
} catch (Exception de)
{
ls_msg = de.Message + de.StackTrace; return "-1 ";
}
}
}
} private void button1_Click(object sender, EventArgs e)
{
string ls_msg1;
string ls_msg2 = component11.Hello("d:\\我.txt", out ls_msg1);
}