블로그 이미지
안녕1999

카테고리

전체 (3067)
자바스크립트 (20)
안드로이드 (14)
WebGL (4)
변비 (17)
정치,경제 (35)
C언어,ARM (162)
컴퓨터(PC, Note Book, 윈.. (41)
전자회로, PCB (27)
유머,안웃긴,GIF,동영상 (118)
국부론60 (71)
모듈(PCB) (3)
건강 (2)
FreeCAD (25)
PADS (43)
퇴직,퇴사,구직,취업 활동 (3)
C# (86)
엑셀 (8)
워드 (0)
LabView (6)
레고 (30)
FPGA (0)
Total
Today
Yesterday

달력

« » 2025.3
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

공지사항

최근에 올라온 글

error CS1955: 호출할 수 없는 멤버인 'xx'은(는) 메서드처럼 사용할 수        없습니다.

멤버중에 함수가 아닌것은 "()" 없이 사용하면 된다.(변수라고 보면 된다)
함수인 경우에만 "()"를 붙여주면 된다.

예)
if(System.IO.Ports.SerialPort.IsOpen())   //err
if(System.IO.Ports.SerialPort.IsOpen)     //ok


public bool IsOpen { get; }    <<== get만 표시되어 있다면, 함수가 아니다.
Posted by 안녕1999
, |
error CS0120: 비정적 필드, 메서드 또는 속성 "xx"에 개체 참조가 필요합니다.

static인 함수에서 static이 아닌, 동적 생성되는 함수나, 변수를 참조하는 경우에 발생.
static은 항상 메모리에 존재하지만, new등으로 생성하는 것들은 항상 메모리에 없기도 하기떄문에 오류가 발생한다.
따라서, static 함수에서는 항상 존재하는 것들만 호출, 참조할 수 있다.

전역변수인 경우에는 static으로 할 경우, 해당 클래스를 사용하는 모든것들은 동일한 변수를 참조할 수 있다는 말이 된다.
해당 클래스가 1개만 생성되는 경우라면, static 변수, 함수, 클래스를 사용하면 된다.

유사한 에러 :
error CS0120: 비정적 필드, 메서드 또는 속성 'xx()'에 개체 참조가 필요합니다.
Posted by 안녕1999
, |

switch(a)
{
case 0: ...; break;
case 1: ...; break;
default:
    ...;
}
error CS0163: 한 case 레이블('default:')에서 다른 case 레이블로 제어를 이동할 수 없습니다.

 

올바른 코드
switch(a)

{
case 0: ...; break;
case 1: ...; break;
default:
    ...;
    break;
}

Posted by 안녕1999
, |

VC++ 6.0으로 컴파일

C# / 2020. 5. 27. 09:37

배치파일 만들어 설정.
컴파일도 되고, 에러 발생시, F4키로 에러소스코드 확인도 가능.
소스코드 칼라적용은 안됨.


set s=D:\PCB\C#\RS232FileTXRX set PATH=%PATH%;%src% set c=C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe rem %c% "%s%\Form1.cs" "%s%\Form1.Designercs" "%s%\Program.cs" %c% "%s%\Program.cs" pause




C:\>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /?
Microsoft (R) Visual C# Compiler version 4.8.3752.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

                        Visual C# 컴파일러 옵션

                        - 출력 파일 -
/out:<파일>                    출력 파일 이름을 지정합니다(기본값: 주 클래스가 있는 파일 또는 첫째 파일의 기본 이름).
/target:exe                    콘솔 실행 파일을 빌드합니다(기본값). (약식: /t:exe)
/target:winexe                 Windows 실행 파일을 빌드합니다. (약식: /t:winexe)
/target:library                라이브러리를 빌드합니다. (약식: /t:library)
/target:module                 다른 어셈블리에 추가될 수 있는 모듈을 빌드합니다. (약식: /t:module)
/target:appcontainerexe        Appcontainer 실행 파일을 빌드합니다. (약식: /t:appcontainerexe)
/target:winmdobj               WinMDExp에서 사용되는 Windows Runtime 중간 파일을 빌드합니다. (약식: /t:winmdobj)
/doc:<파일>                    생성할 XML 문서 파일
/platform:<문자열>             이 코드를 실행할 수 있는 플랫폼을 x86, Itanium, x64, arm, anycpu32bitpreferred 또는
                               anycpu로 제한합니다. 기본값은 anycpu입니다.

                        - 입력 파일 -
/recurse:<와일드카드>          와일드카드 지정에 따라 현재 디렉터리와 하위 디렉터리에 있는 모든 파일을 포함합니다.
/reference:<별칭>=<파일>       지정한 어셈블리 파일에서 해당 별칭을 사용하여 메타데이터를 참조합니다. (약식: /r)
/reference:<파일_목록>         지정한 어셈블리 파일에서 메타데이터를 참조합니다. (약식: /r)
/addmodule:<파일_목록>         지정한 모듈을 이 어셈블리에 링크합니다.
/link:<파일_목록>              지정한 interop 어셈블리 파일에서 메타데이터를 포함하십시오. (약식: /l)

                        - 리소스 -
/win32res:<파일>               Win32 리소스 파일(.res)을 지정합니다.
/win32icon:<파일>              이 아이콘을 사용하여 출력합니다.
/win32manifest:<파일>          Win32 매니페스트 파일(.xml)을 지정하십시오.
/nowin32manifest               기본 Win32 매니페스트를 포함하지 마십시오.
/resource:            지정한 리소스를 포함합니다. (약식: /res)
/linkresource:        지정한 리소스를 이 어셈블리에 링크합니다. (약식: /linkres)
                               resinfo 형식이 <파일>[,<문자열 이름>[,public|private]]인 경우

                        - 코드 생성 -
/debug[+|-]                    디버깅 정보를 내보냅니다.
/debug:{full|pdbonly}          디버깅 형식을 지정합니다. 기본값은 'full'이며, 실행 중인 프로그램에 디버거를 연결합니다.
/optimize[+|-]                 최적화를 사용합니다. (약식: /o)

                        - 오류 및 경고 -
/warnaserror[+|-]              모든 경고를 오류로 보고합니다.
/warnaserror[+|-]:<경고 목록>  특정 경고를 오류로 보고합니다.
/warn:                      경고 수준(0-4)을 설정합니다. (약식: /w)
/nowarn:<경고 목록>            특정 경고 메시지를 사용하지 않습니다.

                        - 언어 -
/checked[+|-]                  오버플로 검사를 생성합니다.
/unsafe[+|-]                   'unsafe' 코드를 사용할 수 있습니다.
/define:<기호 목록>            조건부 컴파일 기호를 정의합니다. (약식: /d)
/langversion:<문자열>          언어 버전 모드를 ISO-1, ISO-2, 3, 4, 5 또는 Default로 지정합니다.

                        - 보안 -
/delaysign[+|-]                강력한 이름 키의 공개 부분만 사용하여 어셈블리 서명을 연기합니다.
/keyfile:<파일>                강력한 이름의 키 파일을 지정합니다.
/keycontainer:<문자열>         강력한 이름의 키 컨테이너를 지정합니다.
/highentropyva[+|-]            높은 엔트로피 ASLR 사용
/enforcecodeintegrity[+|-]     Enforce code intergrity checks on all inputs to the compiler and enable loading compiled
                               assemblies by other programs that enforce code integrity if the operating system is
                               configured to do so.

                        - 기타 -
@<파일>                        추가 옵션에 대한 지시 파일을 읽습니다.
/help                          사용법 메시지를 표시합니다. (약식: /?)
/nologo                        컴파일러 저작권 메시지를 표시하지 않습니다.
/noconfig                      CSC.RSP 파일을 자동으로 포함하지 않습니다.

                        - 고급 -
/baseaddress:<주소>            빌드할 라이브러리의 기준 주소
/bugreport:<파일>              '버그 보고서' 파일을 만듭니다.
/codepage:                  소스 파일을 열 때 사용할 코드 페이지를 지정합니다.
/utf8output                    컴파일러 메시지를 UTF-8 인코딩으로 출력합니다.
/main:<형식>                   진입점을 포함하는 형식을 지정합니다. 다른 모든 가능한 진입점은 무시합니다. (약식: /m)
/fullpaths                     컴파일러가 정규화된 경로를 생성합니다.
/filealign:                 출력 파일 섹션에 사용되는 맞춤을 지정합니다.
/pdb:<파일>                    디버그 정보 파일 이름을 지정합니다(기본값: 확장명이 .pdb인 출력 파일 이름).
/errorendlocation              각 오류의 끝 위치 줄과 열을 출력합니다.
/preferreduilang               기본 출력 언어 이름을 지정합니다.
/nostdlib[+|-]                 표준 라이브러리(mscorlib.dll)를 참조하지 않습니다.
/subsystemversion:<문자열>     이 어셈블리의 하위 시스템 버전 지정
/lib:<파일_목록>               참조를 검색할 추가 디렉터리를 지정합니다.
/errorreport:<문자열>          내부 컴파일러 오류를 처리하는 방법을 지정합니다. prompt, send, queue 또는 none 중에서
                               선택할 수 있으며 기본값은 queue입니다.
/appconfig:<파일>              어셈블리 바인딩 설정을 포함하는 응용 프로그램 구성 파일을 지정합니다.
/moduleassemblyname:<문자열>   이 모듈이 속할 어셈블리의 이름입니다.





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.IO.Ports;
using System.Diagnostics;
using System.Runtime.InteropServices;// DllImport

namespace RS232FileTx
{
    public partial class From1 : Form
    {
        /*void RX_file_write(ref SerialPort p, string file, int len)
        {
            int wlen = 0;
            string temp_file = file + "tmp";
            if (file.Length > 0)
            {
                if (len > 0)
                {
                    using (StreamWriter f = new StreamWriter(temp_file))
                    {
                        char[] buf = new char[1024 * 1024];
                        while (wlen < len)
                        {
                            int blen;
                            blen = p.BytesToRead;
                            if (blen > buf.Length)
                            {
                                blen = buf.Length;
                            }
                            Debug.WriteLine(Convert.ToString(blen));
                            blen = p.Read(buf, 0, blen);
                            f.Write(buf, 0, blen);
                            wlen += blen;
                        }
                        f.Close();
                        if (wlen != len)
                        {
                            //err
                            File.Delete(temp_file);
                        }
                        else
                        {
                            //ok
                            File.Move(temp_file, file);
                        }
                    }
                }
            }
        }
        void RX_file()
        {
            string file_name = "";
            int bExit = 0;
            int file_len = 0;
            SerialPort p;
            p = new SerialPort();
            while (bExit == 0)
            {
                foreach (string name in SerialPort.GetPortNames())
                {
                    p.PortName = name;
                    break;
                }
                Debug.WriteLine(p.PortName);
                p.BaudRate = 115200;
                Debug.WriteLine(Convert.ToString(p.BaudRate));
                p.Open();
                if (p.IsOpen)
                {
                    string c;
                    while (bExit == 0)
                    {
                        c = p.ReadLine();
                        if (c == "FILE")
                        {
                            file_name = p.ReadLine();
                        }
                        else if (c == "LEN")
                        {
                            file_len = Convert.ToInt32(p.ReadLine());
                        }
                        else if (c == "DATA")
                        {
                            RX_file_write(ref p, file_name, file_len);
                        }
                        else if (c == "EXIT")
                        {
                            bExit = 1;
                            break;
                        }
                        else
                        {
                            Debug.WriteLine("??");
                            break;
                        }
                    }
                    p.Close();
                }
            }
        }*/
        long file_size, file_tx_i;
        void PrograssBar_reset()
        {
            progressBar1.Value = 0;
            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
        }
        void PrograssBar_redraw()
        {
            progressBar1.Value = (int)file_tx_i;
            Refresh();
        }
        void UART_write_int(ref SerialPort p,int i)
        {
            byte[] a = BitConverter.GetBytes(i);
            p.Write(a, 0,a.Length);
        }
        int UART_read_int(ref SerialPort p)
        {
            int i=0;
            byte[] a = BitConverter.GetBytes(i);
            p.Read(a, 0, a.Length);
            return BitConverter.ToInt32(a,0);
        }
        int GetCheckSum(byte[]a,int start,int len)
        {
            int i,cs=0;
            for(i=0;i<len;i++)
            {
                cs += a[i] * (i+2);
            }
            return cs;
        }
        int ts, te, e,file_tx_len;
        void Print_Speed()
        {
            te = GetTickCount();
            e = (te - ts)/1000;
            if (e <= 0) e = 1;
            byte_per_sec.Text = (file_tx_len/e).ToString() + " byte/sec";
        }
        void TX_file_with_sum(ref SerialPort p, string file)
        {
            FileInfo fi = new System.IO.FileInfo(file);
            int len = (int)fi.Length, wlen = 0;
            if (p.IsOpen)
            {
                using (BinaryReader f = new BinaryReader(File.Open(file, FileMode.Open)))
                //using (FileStream f = File.Open(file, FileMode.CreateNew))
                {
                    //LogWrite("FILE:"+ len.ToString()+"byte", file);
                    ts=GetTickCount();
                    file_tx_len = 0;

                    file_size = len;
                    file_tx_i = 0;
                    progressBar1.Value = 0;
                    progressBar1.Maximum = len;

                    p.WriteLine("FILE");
                    p.WriteLine(file);

                    p.WriteLine("LEN");
                    p.WriteLine(Convert.ToString(len));

                    p.WriteLine("DATA");
                    byte[] buf = new byte[1024];
                    while (len > 0)
                    {
                        if (len >= buf.Length)
                        {
                            wlen = buf.Length;
                        }
                        else
                        {
                            wlen = len;
                        }
                        wlen = f.Read(buf, 0, wlen);
                        if(wlen<=0)
                        {
                            break;
                        }
                        UART_write_int(ref p,wlen);
                        p.Write(buf, 0, wlen);
                        if(UART_read_int(ref p)==GetCheckSum(buf, 0, wlen))
                        {


                        }
                        else
                        {
                            //err
                            break;
                        }
                        file_tx_i += wlen;
                        len -= wlen;
                        file_tx_len += wlen;
                        // 수신이 잘 이루어지고 있는지 확인

                        PrograssBar_redraw();
                        Print_Speed();
                    }
                    //p.WriteLine("EXIT");
                    PrograssBar_reset();
                    te= GetTickCount();
                    e = te - ts;
                    //LogWrite("Time:", e.ToString()+" "+ (fi.Length/(e/1000)).ToString()+"byte/sec");
                }
            }
        }
        void TX_file(ref SerialPort p, string file)
        {
            FileInfo fi = new System.IO.FileInfo(file);
            int len = (int)fi.Length, wlen = 0;
            if (p.IsOpen)
            {
                //using (StreamReader f = new StreamReader(file))
                using (BinaryReader f = new BinaryReader(File.Open(file, FileMode.Open)))
                //using (FileStream f = File.Open(file, FileMode.Open))
                {
                    //LogWrite("FILE:" + len.ToString() + "byte", file);
                    ts = GetTickCount();
                    file_tx_len += wlen;
                    file_tx_len = 0;

                    file_size = len;
                    file_tx_i = 0;
                    progressBar1.Value = 0;
                    progressBar1.Maximum = len;

                    p.WriteLine("FILE");
                    p.WriteLine(file);

                    p.WriteLine("LEN");
                    p.WriteLine(Convert.ToString(len));

                    p.WriteLine("DATA");
                    byte[] buf = new byte[1024];
                    while (len > 0)
                    {
                        if (len >= buf.Length)
                        {
                            wlen = buf.Length;
                        }
                        else
                        {
                            wlen = len;
                        }
                        wlen = f.Read(buf, 0, wlen);
                        if (wlen <= 0)
                        {
                            break;
                        }
                        p.Write(buf, 0, wlen);
                        file_tx_i += wlen;
                        len -= wlen;
                        file_tx_len += wlen;
                        // 수신이 잘 이루어지고 있는지 확인

                        PrograssBar_redraw();
                        Print_Speed();
                    }
                    //p.WriteLine("EXIT");
                    Print_Speed();
                    PrograssBar_reset();
                    te = GetTickCount();
                    e = te - ts;
                    //LogWrite("Time:", e.ToString() + " " + (fi.Length / (e / 1000)).ToString() + "byte/sec");
                }
            }
        }


        int Sizeof(byte[] buf)
        {
            return buf.Length;
        }

        int GetTickCount()
        {
            return Environment.TickCount;
        }
        string itoa(int i)
        {
            return i.ToString();
        }
        int m_Debug_print_msec_old;
        void DEBUG_print_msec()
        {
            int t, e;
            t = GetTickCount();
            e=t- m_Debug_print_msec_old;
            m_Debug_print_msec_old = t;
            Debug.WriteLine(itoa(e));
        }

        [DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern IntPtr ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);

        [StructLayout(LayoutKind.Sequential)]
        public struct SYSTEMTIME
        {
            public UInt16 wYear;
            public UInt16 wMonth;
            public UInt16 wDayOfWeek;
            public UInt16 wDay;
            public UInt16 wHour;
            public UInt16 wMinute;
            public UInt16 wSecond;
            public UInt16 wMilliseconds;
        }

        [DllImport("kernel32")]
        public static extern void GetLocalTime(out SYSTEMTIME localTime);

        string m_LogFile="",m_LogFile_buf="";
        static UInt16 m_wDay=0, m_wHour=0;
        void LogWrite_flush()
        {
            /*if (m_LogFile_buf.Length > 0)
            {
                FileStream fs = new FileStream(m_LogFile, FileMode.Append, FileAccess.Write);
                //FileMode중 append는 이어쓰기. 파일이 없으면 만든다.
                StreamWriter f = new StreamWriter(fs);//, System.Text.Encoding.UTF8);
                //using (StreamWriter f = new StreamWriter(m_LogFile))
                {
                    f.WriteLine(m_LogFile_buf);
                    f.Close();
                }
                m_LogFile_buf = "";
            }*/
        }
        void LogWrite(string log_type,string s)
        {
            /*SYSTEMTIME t;
            GetLocalTime(out t);

            //DEBUG_print_msec();

            if (t.wHour != m_wHour)
            {
                m_wHour=t.wHour;
                LogWrite_flush();
            }
            if (t.wDay!= m_wDay)
            {
                LogWrite_flush();
                m_wDay = t.wDay;
                m_LogFile = "Log" + m_wDay.ToString("D2") + ".txt";
            }
            m_LogFile_buf += ";"+t.wHour.ToString("D2")+":"+ t.wMinute.ToString("D2") + ":" + t.wSecond.ToString("D2") + ":" + t.wMilliseconds.ToString("D3") +" "+ log_type+"\r\n";
            m_LogFile_buf += s + "\r\n";

            if (m_LogFile_buf.Length > 1024*1024)
            {
                LogWrite_flush();
            }*/
        }
        void FileOpen(string file)
        {
            ShellExecute(this.Handle, "open",file,"","",4);
        }
        void LogFileOpen()
        {
            //FileOpen(m_LogFile);
        }
        void OnKey_F2()
        {
            LogFileOpen();
        }
        void OnTimer_1sec()
        {
            PrograssBar_redraw();
        }
        int m_t100msec;
        void OnTimer()
        {
            m_t100msec++;
            if (m_t100msec >= 10)
            {
                m_t100msec -= 10;
                OnTimer_1sec();
            }
        }
        void MessageBox_Show(string s)
        {
            MessageBox.Show(s);
            //LogWrite("MessageBox", s);
        }







        void DEBUG_event_log_write(object sender, EventArgs e)
        {
            if (sender == this)
            {
                //LogWrite(((From1)sender).ActiveControl.Text, (((From1)sender).ActiveControl.Name));
            }
            else
            {
                //LogWrite(((ButtonBase)sender).Text, (((ButtonBase)sender).Name));
            }
        }
        public From1()
        {
            InitializeComponent();

        }

        private void Combo_Serial_add()
        {
            try
            {
                Combo_Serial_port.Items.Clear();
                foreach (string comport in SerialPort.GetPortNames())
                {
                    Combo_Serial_port.Items.Add(comport);
                    //Combo_Serial_port.Text = comport;
                    OpenCOMPort(ref UART1, comport);
                 }
            }
            catch
            {

            }
        }

        private void Combo_Serial_Click(object sender, EventArgs e)
        {
            try
            {
                Combo_Serial_port.Items.Clear();
                foreach (string comport in SerialPort.GetPortNames())
                {
                    Combo_Serial_port.Items.Add(comport);
                }

            }
            catch
            {

            }
        }

        private void Serial_CLOSE_Click(object sender, EventArgs e)
        {
            DEBUG_event_log_write(sender, e);
            try
            {
                UART1.Close();
                Combo_Serial_port.Text = "";
            }
            catch
            {

            }
        }
        private void OpenCOMPort(ref SerialPort p,string PortName)
        {
            if (PortName != string.Empty)
            {
                if (!p.IsOpen)
                {
                    p.PortName = PortName;
                    try
                    {
                        p.Open();
                    }
                    catch { }

                    if (p.IsOpen)
                    {

                    }
                }
                else
                {

                }
            }
            if (UART1.IsOpen)
            {
                timer2.Start();
                Picture_Serial_state.Image = Properties.Resources.greensmall;
                Combo_Serial_port.Text = UART1.PortName;
            }
            else
            {
                Picture_Serial_state.Image = Properties.Resources.redled;
            }
        }
        private void Combo_Serial_open(object sender, EventArgs e)
        {
            try
            {
                UART1.Close();
                UART1.PortName = Combo_Serial_port.Text;
                UART1.Open();
                //UART1.DataReceived += new SerialDataReceivedEventHandler(Serial_DataReceived);
            }
            catch
            {
                
            }
            if ((UART1.IsOpen)&&(UART1.PortName == Combo_Serial_port.Text))
            {
                Picture_Serial_state.Image = Properties.Resources.greensmall;
                timer2.Start();
            }
            else
            {
                Picture_Serial_state.Image = Properties.Resources.redled;
            }
        }


        private void timer1_Tick(object sender, EventArgs e)
        {
            OnTimer();            
        }


        private void OnRx(ref Byte [] buf,int Serial_Data_counter)
        {
            
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (UART1.IsOpen)
            {
                int Serial_Data_counter = UART1.BytesToRead;
                try
                {
                    Byte[] buf = new Byte[Serial_Data_counter];
                    UART1.Read(buf, 0, Serial_Data_counter);
                    OnRx(ref buf,Serial_Data_counter);
                }
                catch { }
            }
        }



        static void RX_file_write(ref SerialPort p, string file, int len)
        {
            int wlen = 0;
            string temp_file = file + "tmp";
            if (file.Length > 0)
            {
                if (len > 0)
                {
                    //using (StreamWriter f = new StreamWriter(temp_file))
                    using (BinaryWriter f = new BinaryWriter(File.Open(file, FileMode.Create)))
                    //using (FileStream f = File.Open(temp_file, FileMode.CreateNew))
                    {
                        byte[] buf = new byte[1024 * 1024];
                        while (wlen < len)
                        {
                            int blen;
                            blen = p.BytesToRead;
                            if (blen > buf.Length)
                            {
                                blen = buf.Length;
                            }
                            Debug.WriteLine(Convert.ToString(blen));
                            blen = p.Read(buf, 0, blen);
                            f.Write(buf, 0, blen);
                            wlen += blen;
                        }
                        f.Close();
                        if (wlen != len)
                        {
                            //err
                            File.Delete(temp_file);
                        }
                        else
                        {
                            //ok
                            File.Move(temp_file, file);
                        }
                    }
                }
            }
        }
        static void RX_file()
        {
            string file_name = "";
            int bExit = 0;
            int file_len = 0;
            SerialPort p;
            p = new SerialPort();
            while (bExit == 0)
            {
                foreach (string name in SerialPort.GetPortNames())
                {
                    p.PortName = name;
                    p.Open();
                    if (p.IsOpen)
                    {
                        break;
                    }
                }
                Debug.WriteLine(p.PortName);
                p.BaudRate = 115200;
                Debug.WriteLine(Convert.ToString(p.BaudRate));
                if (p.IsOpen)
                {
                    string c;
                    while (bExit == 0)
                    {
                        c = p.ReadLine();
                        if (c == "FILE")
                        {
                            file_name = p.ReadLine();
                            file_name=file_name.Substring(file_name.LastIndexOf('\\')+1);
                        }
                        else if (c == "LEN")
                        {
                            file_len = Convert.ToInt32(p.ReadLine());
                        }
                        else if (c == "DATA")
                        {
                            RX_file_write(ref p, file_name, file_len);
                        }
                        else if (c == "EXIT")
                        {
                            bExit = 1;
                            break;
                        }
                        else
                        {
                            Debug.WriteLine(c);
                            //break;
                        }
                    }
                    p.Close();
                }
            }
        }


        private void From1_Load(object sender, EventArgs e)
        {
            //RX_file();
            Combo_Serial_add();
        }

        private void button_file_Click(object sender, EventArgs e)
        {
            if (UART1.IsOpen)
            {
                var fileContent = string.Empty;
                var filePath = string.Empty;

                using (OpenFileDialog openFileDialog = new OpenFileDialog())
                {
                    //openFileDialog.InitialDirectory = "c:\\";
                    openFileDialog.Filter = "All files (*.*)|*.*";
                    openFileDialog.FilterIndex = 2;
                    openFileDialog.RestoreDirectory = true;

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        TX_file(ref UART1, openFileDialog.FileName);
                        /*//Get the path of specified file
                        filePath = openFileDialog.FileName;

                        //Read the contents of the file into a stream
                        var fileStream = openFileDialog.OpenFile();

                        using (StreamReader reader = new StreamReader(fileStream))
                        {
                            fileContent = reader.ReadToEnd();
                        }*/
                    }
                }
            }
        }

        private void Combo_Serial_port_SelectionChangeCommitted(object sender, EventArgs e)
        {
            UART1.Close();
            OpenCOMPort(ref UART1, Combo_Serial_port.Text);
        }

        private void From1_DragDrop(object sender, DragEventArgs e)
        {
            // Ensure that the list item index is contained in the data.
            if (e.Data.GetDataPresent(typeof(System.String)))
            {

                Object item = (object)e.Data.GetData(typeof(System.String));

                // Perform drag-and-drop, depending upon the effect.
                if (e.Effect == DragDropEffects.Copy ||
                    e.Effect == DragDropEffects.Move)
                {

                    // Insert the item.
                    //if (indexOfItemUnderMouseToDrop != ListBox.NoMatches)
                    //    ListDragTarget.Items.Insert(indexOfItemUnderMouseToDrop, item);
                    //else
                    //    ListDragTarget.Items.Add(item);
                }
            }
            // Reset the label text.
            //DropLocationLabel.Text = "None";
        }

        private void From1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (UART1.IsOpen)
            {
                UART1.WriteLine("EXIT");
                UART1.Close();
            }
            LogWrite_flush();
        }

        private void From1_KeyDown(object sender, KeyEventArgs e)
        {
            switch(e.KeyCode)//안됨
            {
                case Keys.F2:
                    OnKey_F2();
                    break;
                default:
                    break;
            }
        }
    }
}





set c=C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
%c% /out:RX.exe rx.c
pause


using System;
using System.IO.Ports;
using System.IO;
using System.Diagnostics;

namespace RS232FileRx
{
	class Rs232Rx
	{
		static void RX_file_write(ref SerialPort p, string file, int len)
		{
			int wlen=0;
			string temp_file=file+".tmp";
			File.Delete(temp_file);
			if(file.Length>0)
			{
				if(len>0)
				{
					using(BinaryWriter f=new BinaryWriter(File.Open(temp_file,FileMode.Create)))
					{
						byte[] buf=new byte[1024*1024];
						while(wlen<len)
						{
							int blen;
							blen=p.BytesToRead;
							if(blen>buf.Length)
							{
								blen=buf.Length;
							}
							blen=p.Read(buf,0,blen);
							f.Write(buf,0,blen);
							wlen+=blen;
						}
						f.Close();
						if(wlen!=len)
						{
							File.Delete(temp_file);
						}
						else
						{
							File.Delete(file);
							File.Move(temp_file,file);
						}
					}
				}
			}
		}
		static void RX_file()
		{
			string file_name="";
			int bExit=0;
			int file_len=0;
			SerialPort p;
			p=new SerialPort();
			p.BaudRate=115200;
			while(bExit==0)
			{
				try{
					p.PortName="COM6";
					p.Open();
					if(!p.IsOpen)
					{
						foreach(string name in SerialPort.GetPortNames())
						{
							p.PortName=name;
							p.Open();
							if(p.IsOpen)
							{
								break;
							}
						}
					}
				}
				catch{}
				if(p.IsOpen)
				{
					string c;
					while(bExit==0)
					{
						c=p.ReadLine();
						if(c=="FILE")
						{
							file_name=p.ReadLine();
							file_name=file_name.Substring(file_name.LastIndexOf('\\')+1);
						}
						else if(c=="LEN")
						{
							file_len=Convert.ToInt32(p.ReadLine());
						}
						else if(c=="DATA")
						{
							RX_file_write(ref p, file_name,file_len);
						}
						else if(c=="EXIT")
						{
							bExit=1;
							break;
						}
						else
						{
						}
					}
					p.Close();
				}
			}
		}
		public static void Main()
		{
			RX_file();
		}
	}
}
























Posted by 안녕1999
, |

- zip프로그램이 없어도 동작함.(윈도우 압축기능 사용)(장점)

- 지정된 파일이 한개라도 없으면, 압축파일이 생성되지 않음.(단점)

- 7zip보다 느림.(단점)



REM 불필요한 파일 삭제
del /s *.lss
del /s *.srec
del /s *.o
del /s *.crf
del /s *.map
del /s *.dep
del /s *.d
del /s *.afx
del /s *.cache
del /s *.pdb
del /s *.cache
del /s *.Resources.resources
del /s TemporaryGeneratedFile_*.cs
del /s Properties.Resources.Designer.cs.dll
del /s Makefile
del /s *.mk





rem 공백없이

rem 압축할 폴더이름
set f=bbbb

rem 압축된 파일 이름 예) xxx-20200525-14.zip
set zip=aaaaa-%date%-%time:~0,2%.zip

rem 여러파일을 나열할 수 없음. 한번씩 추가
rem powershell에서는 파일이름에 공백이 있는 경우 문제가 된다. '...'추가
powershell Compress-Archive -Path "%f%" -Update -DestinationPath "'%zip%'"

rem 파일이 없다면 zip파일이 삭제된다.(압축파일이 생성되지 않는다면, 확인해보세요)
set f="*.bat"
if exist %f% (
	powershell Compress-Archive -Path %f% -Update -DestinationPath "'%zip%'"
)

set f="*.txt"
if exist %f% (
	powershell Compress-Archive -Path %f% -Update -DestinationPath "'%zip%'"
)

set f="*.bat"
if exist %f% (
	powershell Compress-Archive -Path %f% -Update -DestinationPath "'%zip%'"
)

set f="*.atsln"
if exist %f% (
	powershell Compress-Archive -Path %f% -Update -DestinationPath "'%zip%'"
)

set f="*.sln"
if exist %f% (
	powershell Compress-Archive -Path %f% -Update -DestinationPath "'%zip%'"
)

explorer "%zip%"
copy "%zip%" "\\SERVER\xxxxx\%zip%"
pause

 

Posted by 안녕1999
, |

while(len)
error CS0029: Cannot implicitly convert type 'int' to 'bool'


while(len>0)

'C#' 카테고리의 다른 글

VC++ 6.0으로 컴파일  (0) 2020.05.27
c# - 소스파일 압축 백업 - xbackup.bat  (0) 2020.05.25
error CS1525: Invalid expression term 'char'  (0) 2020.05.25
error CS1003: Syntax error, ']' expected  (0) 2020.05.25
전역변수  (0) 2020.05.25
Posted by 안녕1999
, |

char[1024] buf;
error CS1525: Invalid expression term 'char'

char[] buf=new char[1024];

Posted by 안녕1999
, |

byte[] buf=new [blen];
error CS1003: Syntax error, ']' expected


byte[] buf=new byte[blen];

Posted by 안녕1999
, |

전역변수

C# / 2020. 5. 25. 00:02

C#은 전역변수 사용할 수 없다.
const나 static등을 사용하며, 클래스의 멤버변수를 참조하도록 한다.

Posted by 안녕1999
, |

RS232FileTXRX.zip
0.00MB
RS232FileTXRX-.zip
0.00MB

type com1: >> data.log

 

mode COM21 BAUD=115200 PARITY=n DATA=8

copy yourfile.txt /B \\.\COM21

@Echo Off
echo 1l. > COM6:
SetLocal
Set Handle=%@FileOpen[COM6:,r,b]
Set Char=%@FileRead[%Handle,1]
Set Count=0
Do While "%Char" != "**EOF**"
Do While "%Count" <= 999 
  Set /A Count+=1
  @EchoS %Count: %Char^n
  Set Char=%@FileRead[%Handle,1]
EndDo
EndLocal
Pause

 

 

namespace SerialPortExample
{
  class SerialPortProgram
  {
    // Create the serial port with basic settings
    private SerialPort port = new SerialPort("COM1",
      9600, Parity.None, 8, StopBits.One);

    [STAThread]
    static void Main(string[] args)
    { 
      // Instatiate this class
      new SerialPortProgram();
    }

    private SerialPortProgram()
    {
      Console.WriteLine("Incoming Data:");

      // Attach a method to be called when there
      // is data waiting in the port's buffer
      port.DataReceived += new 
        SerialDataReceivedEventHandler(port_DataReceived);

      // Begin communications
      port.Open();

      // Enter an application loop to keep this thread alive
      Application.Run();
    }

    private void port_DataReceived(object sender,
      SerialDataReceivedEventArgs e)
    {
      // Show all the incoming data in the port's buffer
      Console.WriteLine(port.ReadExisting());
    }
  }
}












using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using class
using System.IO.Ports;
using System.Text;
using System.Windows.Forms;
 
namespace SensingWaterLeak
{
    public partial class MainLeakInfo : Form
    {
        private SerialPort mSerialPort;
 
        public MainLeakInfo()
        {
            InitializeComponent();
        }
 
        private void btn_leak_data_load_Click(object sender, EventArgs e)
        {
        }
 
        private void btn_leak_data_send_Click(object sender, EventArgs e)
        {
            try
            {
                if (mSerialPort != null && mSerialPort.IsOpen)
                {
                    mSerialPort.Close();
                    mSerialPort = null;
                }
                //Comport 와, baudRate 설정
                //USB의 기본 파라미터 설정을 해줌
                mSerialPort = new SerialPort("COM6", 9600);
                mSerialPort.Encoding = Encoding.Default;
                mSerialPort.Parity = Parity.None;
                mSerialPort.DataBits = 8;
                mSerialPort.StopBits = StopBits.One;
                //USB device로 부터 message receive시 callback 되는 listener
                mSerialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
                //Open을 했으면 close는 필수
                mSerialPort.Open();
                listBox.Items.Add("open 성공");
                byte[] buffer = new byte[3] {0xAA, 0xBB, 0xFB};
                //write 성공
                mSerialPort.Write(buffer, 0, 3);
                
                listBox.Items.Add("write");
            }
            catch (Exception eu)
            {
                System.Console.Out.WriteLine(eu.ToString());
                listBox.Items.Add(eu.ToString());
            }
 
        }
 
        private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            System.Console.Out.WriteLine("===============recevied================");
            try
            {
                listBox.Items.Add(mSerialPort.ReadLine());
            }
            catch (Exception et)
            {
                System.Console.Out.WriteLine(et.ToString());
            }
        }
    }
}



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
// 필요한 class를 using 해주자
using LibUsbDotNet.DeviceNotify;
using LibUsbDotNet;
using LibUsbDotNet.Main;
 
 
namespace SensingWaterLeak
{
    public partial class MainLeakInfo : Form
    {
        //변수 선언
        public static IDeviceNotifier mUsbDeviceNotifier = DeviceNotifier.OpenDeviceNotifier();
        public static UsbDeviceFinder mUsbDeviceFinder;
        public static UsbDevice mUsbDevice;
 
        SerialPort mSerialPort;
        public MainLeakInfo()
        {
            InitializeComponent();
			//Device change listener
			mUsbDeviceNotifier.OnDeviceNotify += OnDeviceNotifyEvent;
        }
 
        private void btn_device_no_load_Click(object sender, EventArgs e)
        {
            loadUSB();
        }
        
        //USB 연결/해제시 호출됨
        private void OnDeviceNotifyEvent(object sender, DeviceNotifyEventArgs e)
        {
            listBox.Items.Clear();
            listBox.Items.Add("type :" + e.EventType);
            listBox.Items.Add("Object :" + e.Object);
            listBox.Items.Add("port :" + e.Port);
            listBox.Items.Add("Volume :" + e.Volume);
            if (e.Device != null)
            {
                listBox.Items.Add("vID :" + e.Device.IdVendor);
                listBox.Items.Add("pID :" + e.Device.IdProduct);
                listBox.Items.Add("SerialNumber :" + e.Device.SerialNumber);
                listBox.Items.Add("SymbolicName :" + e.Device.SymbolicName);
                listBox.Items.Add("Name :" + e.Device.Name);
                listBox.Items.Add("ClassGuid :" + e.Device.ClassGuid);
            }
        }
 
        //USB device를 read 한다
        private void loadUSB()
        {
            try
            {
                //finder 방법은 시리얼, vendorID, productID 등의 여러가지 방법이 있다.
                mUsbDeviceFinder = new UsbDeviceFinder("0001");
                //mUsbDeviceFinder = new UsbDeviceFinder("a5dcbf10-6530-11d2-901f-00c04fb951ed");
 
                mUsbDevice = UsbDevice.OpenUsbDevice(mUsbDeviceFinder);
 
                if (mUsbDevice == null)
                {
                    listBox.Items.Add("device is null");
                    return;
                }
 
                IUsbDevice wholeUsbDevice = mUsbDevice as IUsbDevice;
                if (!ReferenceEquals(wholeUsbDevice, null))
                {
                    wholeUsbDevice.SetConfiguration(1);
                    wholeUsbDevice.ClaimInterface(0);
                }
 
                UsbEndpointReader reader = mUsbDevice.OpenEndpointReader(ReadEndpointID.Ep01);
 
            }
            catch (Exception e)
            {
                listBox.Items.Add(e.ToString());
            }
 
        }
    }
}
[출처] C# USB 통신 방법 - LibUsbDotNet|작성자 모암스






using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using LibUsbDotNet;
using LibUsbDotNet.Info;
using LibUsbDotNet.Main;
namespace USB
{
    public partial class Form1 : Form
    {
        public static UsbDevice usbDevice;
        public static UsbRegistry [] usbRegistry;
        public static int nIdx;
        public UsbEndpointReader reader;
        delegate void txtBox(RichTextBox tb, string text);

        public Form1()
        {
            InitializeComponent();
            //컴퓨터에 연결된 USB 모든장치 로드
            UsbRegDeviceList allDevice = UsbDevice.AllDevices;
            usbRegistry = new UsbRegistry[allDevice.Count];
            int cntUsb = 0;
            //장치들을 하나씩 돌아가면서 조회
            foreach (UsbRegistry tmpUsbRegistry in allDevice)
            {
                //해당 USB가 정상적으로 열리면
                if(tmpUsbRegistry.Open(out usbDevice))
                {
                    //항목들을 하나씩 리스트박스에 추가
                    usbRegistry[cntUsb] = tmpUsbRegistry;
                    listBox1.Items.Add(usbRegistry[cntUsb].FullName);
                }
                cntUsb++;
            }
            UsbDevice.Exit();
        }
        public void setText(RichTextBox txt, string str)
        {
            if (richTextBox1.InvokeRequired)
            {
                txtBox ci = new txtBox(setText);
                richTextBox1.Invoke(ci, richTextBox1, str);
            }
            else
            {
                richTextBox1.Text =  str + "\r\n" + richTextBox1.Text;
            }
        }
        private void listBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            //리스트박스에서 선택된 USB 인덱스
            nIdx = ((System.Windows.Forms.ListBox)(sender)).SelectedIndex; 
            fldManufacturer.Text = (usbRegistry[nIdx].Device).Info.ManufacturerString;
            fldRev.Text = usbRegistry[nIdx].Rev.ToString();
            fldProduct.Text = (usbRegistry[nIdx].Device).Info.ProductString;
            fldSerial.Text = (usbRegistry[nIdx].Device).Info.SerialString;
            fldProductID.Text = usbRegistry[nIdx].Pid.ToString();
            fldVendorID.Text = usbRegistry[nIdx].Vid.ToString();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //데이터 수신 준비
            IUsbDevice wholeUsbDevice = usbDevice as IUsbDevice;
            //USB에서 들어오는 신호를 받기위해 EndPoint 설정
            reader = usbDevice.OpenEndpointReader(ReadEndpointID.Ep02);
            ReadEventinitStart();
            if (!ReferenceEquals(wholeUsbDevice, null))
            {
                wholeUsbDevice.SetConfiguration(1);
                wholeUsbDevice.ClaimInterface(0);
            }
        }
        public void ReadEvent(object sender, EndpointDataEventArgs e)
        {
            //USB에서 신호가 들어오면 활성화 되는 이벤트
            //string str = UnicodeEncoding.ASCII.GetString(e.Buffer, 0, e.Count);
            string str  = BitConverter.ToInt64(e.Buffer, 0).ToString();
            try
            {
                //받아온 데이터를 기록한다.
                setText(richTextBox1, str);
            }
            catch (System.Exception ex)
            {
            }
        }
        public void ReadEventinitStart()
        {
            //리더 활성화
            reader.DataReceivedEnabled = true;
            //이벤트 핸들러 연결
            reader.DataReceived += (ReadEvent);
        }
    }
}
using System;
using System.IO.Ports;

class PortDataReceived
{
	public static void Main()
	{
		SerialPort mySerialPort = new SerialPort("COM1");

		mySerialPort.BaudRate = 9600;
		mySerialPort.Parity = Parity.None;
		mySerialPort.StopBits = StopBits.One;
		mySerialPort.DataBits = 8;
		mySerialPort.Handshake = Handshake.None;
		mySerialPort.RtsEnable = true;

		mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

		mySerialPort.Open();

		Console.WriteLine("Press any key to continue...");
		Console.WriteLine();
		Console.ReadKey();
		mySerialPort.Close();
	}

	private static void DataReceivedHandler(
						object sender,
						SerialDataReceivedEventArgs e)
	{
		SerialPort sp = (SerialPort)sender;
		string indata = sp.ReadExisting();
		Console.WriteLine("Data Received:");
		Console.Write(indata);
	}
}
/*using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using class
using System.IO.Ports;
using System.Text;
using System.Windows.Forms;*/

using System;
using System.IO.Ports;
using System.IO;
using System.Diagnostics;

namespace RS232FileRx
{
	class Rs232Rx
	{
		static void RX_file_write(ref SerialPort p, string file, int len)
        {
            int wlen = 0;
            string temp_file = file + ".tmp";
			Debug.WriteLine("RX_file_write()");
            if (file.Length > 0)
            {
                if (len > 0)
                {
                    //using (StreamWriter f = new StreamWriter(temp_file))
					using (BinaryWriter f = new BinaryWriter(File.Open(temp_file, FileMode.Create)))
					//using (FileStream f = File.Open(temp_file, FileMode.CreateNew))
                    {
                        byte[] buf = new byte[1024 * 1024];
                        while (wlen < len)
                        {
                            int blen;
                            blen = p.BytesToRead;
                            if (blen > buf.Length)
                            {
                                blen = buf.Length;
                            }
                            Debug.WriteLine(Convert.ToString(blen));
                            blen = p.Read(buf, 0, blen);
                            f.Write(buf, 0, blen);
                            wlen += blen;
                        }
                        f.Close();
                        if (wlen != len)
                        {
                            //err
                            File.Delete(temp_file);
                        }
                        else
                        {
                            //ok
                            File.Move(temp_file, file);
                        }
                    }
                }
            }
        }
        static void RX_file()//20200605
        {
            string file_name = "";
            int bExit = 0;
            int file_len = 0;
            SerialPort p;

			Debug.WriteLine("RX_file()");
            p = new SerialPort();
            while (bExit == 0)
            {
                foreach (string name in SerialPort.GetPortNames())
                {
					Debug.WriteLine(name);
                    p.PortName = name;
                    p.Open();
                    if (p.IsOpen)
                    {
                        break;
                    }
                }
                Debug.WriteLine(p.PortName);
                p.BaudRate = 115200;
                Debug.WriteLine(Convert.ToString(p.BaudRate));
                if (p.IsOpen)
                {
                    string c;
                    while (bExit == 0)
                    {
                        c = p.ReadLine();
						Debug.WriteLine(c);
                        if (c == "FILE")
                        {
                            file_name = p.ReadLine();
							file_name=file_name.Substring(file_name.LastIndexOf('\\')+1);//경로명 잘라내기
                        }
                        else if (c == "LEN")
                        {
                            file_len = Convert.ToInt32(p.ReadLine());
                        }
                        else if (c == "DATA")
                        {
                            RX_file_write(ref p, file_name, file_len);
                        }
                        else if (c == "EXIT")
                        {
                            bExit = 1;
                            break;
                        }
                        else
                        {
                            //Debug.WriteLine(c);
                            //break;
                        }
                    }
                    p.Close();
                }
            }
        }

		//error CS0120: 비정적 필드, 메서드 또는 속성 'Rs232Rx.RX_file()'에 개체 참조가 필요합니다.
		public static void Main()
		{
			RX_file();
			Debug.WriteLine("exit()");
		}
	}
}

set c=C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
%c% /out:compile.exe "main.c"



static void RX_file_write(ref SerialPort p, string file, int len)
        {
            int wlen = 0;
            string temp_file = file + ".tmp";
            if (file.Length > 0)
            {
                if (len > 0)
                {
                    //using (StreamWriter f = new StreamWriter(temp_file))
                    using (BinaryWriter f = new BinaryWriter(File.Open(file, FileMode.Create)))
                    //using (FileStream f = File.Open(temp_file, FileMode.CreateNew))
                    {
                        byte[] buf = new byte[1024 * 1024];
                        while (wlen < len)
                        {
                            int blen;
                            blen = p.BytesToRead;
                            if (blen > buf.Length)
                            {
                                blen = buf.Length;
                            }
                            Debug.WriteLine(Convert.ToString(blen));
                            blen = p.Read(buf, 0, blen);
                            f.Write(buf, 0, blen);
                            wlen += blen;
                        }
                        f.Close();
                        if (wlen != len)
                        {
                            //err
                            File.Delete(temp_file);
                        }
                        else
                        {
                            //ok
                            File.Move(temp_file, file);
                        }
                    }
                }
            }
        }
        static void RX_file()//20200605
        {
            string file_name = "";
            int bExit = 0;
            int file_len = 0;
            SerialPort p;
            p = new SerialPort();
            while (bExit == 0)
            {
                foreach (string name in SerialPort.GetPortNames())
                {
                    p.PortName = name;
                    p.Open();
                    if (p.IsOpen)
                    {
                        break;
                    }
                }
                Debug.WriteLine(p.PortName);
                p.BaudRate = 115200;
                Debug.WriteLine(Convert.ToString(p.BaudRate));
                if (p.IsOpen)
                {
                    string c;
                    while (bExit == 0)
                    {
                        c = p.ReadLine();
                        if (c == "FILE")
                        {
                            file_name = p.ReadLine();
                            file_name=file_name.Substring(file_name.LastIndexOf('\\')+1);
                        }
                        else if (c == "LEN")
                        {
                            file_len = Convert.ToInt32(p.ReadLine());
                        }
                        else if (c == "DATA")
                        {
                            RX_file_write(ref p, file_name, file_len);
                        }
                        else if (c == "EXIT")
                        {
                            bExit = 1;
                            break;
                        }
                        else
                        {
                            Debug.WriteLine(c);
                            //break;
                        }
                    }
                    p.Close();
                }
            }
        }
Posted by 안녕1999
, |

최근에 달린 댓글

글 보관함