我制做了以下一个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";
             }             
         }
    }
}

解决方案 »

  1.   

    ?我试过了可以啊using System;
    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);
            }
      

  2.   

    我测试程序是用powerbuild调用组件的。 就会出现我说的情况?
      

  3.   

    我测试程序是用powerbuild调用组件的。 就会出现我说的情况?
      

  4.   

    我测试程序是用powerbuild调用组件的。 就会出现我说的情况?