본문 바로가기

c# .net

(13)
파일 업로드 소스 주의 : FileUpload 컴퍼넌트 추가 후 사용 참고 : 같은 이름의 파일이 존재할 경우 "filename_x.ext" 형식으로 파일을 업로드 함 ========= 파일 업로드 ========== if (FileUpload1.HasFile) { string upDir = "E:\\Study\\Web\\EmsClient\\Upload\\"; DirectoryInfo di = new DirectoryInfo(upDir); if (!di.Exists) di.Create(); string fName = FileUpload1.FileName; string fFullName = upDir + fName; FileInfo fInfo = new FileInfo(fFullName); if (fInfo.Exists) ..
c#에서 타이머 사용하기 Timer aTimer = new Timer(); // Hook up the Elapsed event for the timer. aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); // Set the Interval to 5 seconds (5000 milliseconds). aTimer.Interval = 5000; aTimer.Enabled = true; void OnTimedEvent(object source, ElapsedEventArgs e) { // Todo:: 할일... }
Master Page 사용하기 [xxx.master] 컨텐츠가 들어갈 부분에 다음과 같은 코드 삽입 [yyy.aspx] 상단 부분에 다음 코드 삽입 본문에 다음 코드로 시작 Page Start!! 위와 같이 사용하면 aspx 컨텐츠가 master 페이지의 컨텐츠 삽입 부분에 들어가 페이지를 완성 시켜준다. ================================================================================ - Content 페이지에서 Master 페이지에 있는 컨트롤 접근 방법 ControlIdType tempId = (ControlIdType)Master.FindControl("CONTROL ID");
c#에서 배열을 참조로 넘기기 C를 하다 C#을 하니 다른점이 많다. 지금 다룰 배열도 그 한가지인데 C에서는 포인터로 넘겨버리면 되었지만 여기선 'ref' 를 쓴다. ref를 빼먹으면 단순 배열 복사가 이루어진다. byte[] cmd_tmp; CvtStructToBin(test_struct, ref cmd_tmp); public int CvtStructToBin(object obj, ref byte[] bin) { int length = Marshal.SizeOf(obj); IntPtr cmd_ptr; cmd_ptr = Marshal.AllocHGlobal(length); bin = new byte[length]; Marshal.StructureToPtr(test_struct, cmd_ptr, true); Marshal.Copy(c..
C#에서 고정 크기 구조체 사용과 바이트 배열로 형 변환 public struct Test_Struct_t { public byte var1; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public char[] str; // (1) //public char[] str; // (2) } public class AP_DB_Cmd_Box : AP_DB_Common { // protected members Test_Struct_t test_struct; int length; byte[] cmd_tmp; IntPtr cmd_ptr; public AP_DB_Cmd_Box() : base() { test_struct.str = new char[10]; // 꼭 해줘야한다. 안그럼 아래에서 에러 test_struct.va..