Announcement

Collapse
No announcement yet.

[help]lổi tên file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [C#] [help]lổi tên file

    PHP Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Messaging;

    namespace 
    hdhthuchanh
    {
        class 
    Program
        
    {
            
    int[] = new int[20];
            
    int[] = new int[20];
            
    int diem 0;
            
    string chuoi "";
            public class 
    truyen
            
    {
                public 
    int[] so1=new int[20];
                public 
    int[] so2 = new int[20];
                public 
    string dau "";
            };
            public 
    void SendMessage()
            {

                
    // Create a new order and set values.
                  
    truyen truyennew= new truyen();
                  
    //for (int i = 0; i < diem; i++)
                  //{
                  //    truyennew.so1[i] =x[i] ;
                  //}
                  //for (int i = 0; i < diem; i++)
                  //{
                  //    truyennew.so2[i] = y[i];
                  //}
                  //truyennew.dau = chuoi;
                // Connect to a queue on the local computer.



                 
    MessageQueue myQueue = new MessageQueue("F:/c#/rua.txt");// khúc này bị vướn nhá mà xác nhận lổi chổ này





                // Send the Order to the queue.
               
    myQueue.Send(truyennew);
                return;
            }
            
    //public void PathExample()
            //{
            //    // Connect to a queue on the local computer.
            //    MessageQueue queue = new MessageQueue(".\\exampleQueue");

            //    // Create a new instance of MessageQueuePermissionEntry.
            //    MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
            //        MessageQueuePermissionAccess.Receive,
            //        queue.Path);

            //    // Display the value of the entry's Path property.
            //    Console.WriteLine("Path: {0}", entry.Path);
            //}
            
    public void ReceiveMessage()
            {
                
    // Connect to the a queue on the local computer.
                
    MessageQueue myQueue = new MessageQueue("F:/c#/rua.txt",true);

                
    // Set the formatter to indicate body contains an Order.
                
    myQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(hdhthuchanh.Program.truyen) });

                try
                {
                    
    // Receive and format the message. 
                    
    Message myMessage myQueue.Receive();
                    
    truyen myOrder = (truyen)myMessage.Body;

                    
    // Display message information.
                    
    for (int i 0diem;i++ )
                    {
                        
    Console.WriteLine(myOrder.so1[i].ToString());
                  
                     }
                }

                catch (
    MessageQueueException)
                {
                    
    // Handle Message Queuing exceptions.
                
    }

                
    // Handle invalid serialization format. 
                
    catch (InvalidOperationException e)
                {
                    
    Console.WriteLine(e.Message);
                }

                
    // Catch other exceptions as necessary. 

                
    return;
                 
            }
            static 
    void Main(string[] args)
            {
                
    int[] = new int[20];
                
    int[] = new int[20];
                
    int diem 0;
                
    string chuoi="";
                
    string temp;
                
    StreamReader sr = new StreamReader(@"C:\Users\11520_000\Documents\Visual Studio 2010\Projects\hdhthuchanh\huy.txt");
                
    //temp=sr.ReadLine();
                //console.WriteLine(temp);
                
    do
                {

                    
    temp sr.ReadLine();
                    
    //Console.WriteLine(temp);

                    
    int i 00000;
                    do
                    {
                        if (
    temp[i].ToString() == "+") { i; break; }
                        if (
    temp[i].ToString() == "-") { i; break; }
                        if (
    temp[i].ToString() == "*") { i; break; }
                        if (
    temp[i].ToString() == "/") { i; break; }
                        
    i++;
                    } while (
    true);
                    
    //Console.WriteLine(a.ToString());
                    
    int e 1;

                    for (
    int j 1>= 0j--)
                    {

                        
    + (temp[j] - 48) * e;
                        
    10;
                    }

                    
    x[diem] = s;
                    
    //Console.WriteLine(s.ToString());
                    
    int r 1;
                    for (
    int j 1temp.Lengthj++)
                    {
                        
    + (temp[j] - 48) * r;
                        
    10;
                    }
                    
    y[diem] = k;
                   
    // Console.WriteLine(k.ToString());

                    //if (temp[a].ToString() == "+")
                    //    o = k + s;
                    //if (temp[a].ToString() == "-")
                    //    o = k - s;
                    //if (temp[a].ToString() == "*")
                    //    o = k * s;
                    //if (temp[a].ToString() == "/")
                    //    o = k / s;
                    //Console.WriteLine(o.ToString() + "ket qua");
                    
    diem++;
                    
    chuoi chuoi temp[a].ToString();
                } while (!
    sr.EndOfStream);
                for (
    int i 0diemi++)
                {
                    
    Console.WriteLine(x[i].ToString() + "   ");
                }
                
    Console.WriteLine("\n");
                for (
    int i 0diemi++)
                {
                    
    Console.WriteLine(y[i].ToString() + "   ");
                }
                
    Console.WriteLine("\n");
                
    Console.WriteLine(chuoi);
                
    // Create a new instance of the class.
                
    Program myNewQueue = new Program();

                
    //// Send a message to a queue.
                
    myNewQueue.SendMessage();

                
    //// Receive a message from a queue.
                //myNewQueue.ReceiveMessage();




            
    }
        }

    theo em dòng này bị lổi mà em không biết có phải không nữa MessageQueue myQueue = new MessageQueue("F:/c#/rua.txt");
    anh nào biết chỉ em với thank nhiều

  • #2
    hình như chuỗi tên file sai bạn ah: bạn dung 2 chuỗi này @"F:/c#/rua.txt" hoặc "F://C#//rua.txt"
    Hãy là chính mình!

    Comment


    • #3
      Muốn kiểm tra xem đường dẫn file có đúng hay không bạn dùng hàm Directory.Exist
      Waiting for the day my nickname get painted black and underlined ...!

      Comment

      LHQC

      Collapse
      Working...
      X