private void okBtn_Click(object sender, EventArgs e) { if (!idBox.Text.Equals("") && !pwBox.Text.Equals("")) { String url = UserInfo.serverUrl + "roomEnter"; byte[] _key; try { _key = Key.load_key(roomId); } catch { MessageBox.Show("해당 방의 KEY파일이 존재하지 않습니다.\n KEY파일을 등록해주세요.", "경고", MessageBoxButtons.OK); OpenFileDialog _Keyfile = new OpenFileDialog(); _Keyfile.Filter = "Key File(*.scf)|*.scf"; _Keyfile.InitialDirectory = "."; _Keyfile.Title = "Select a Key"; if (_Keyfile.ShowDialog() != DialogResult.OK) { return; } else { _key = File.ReadAllBytes(_Keyfile.FileName); } } UserInfo.Key = _key; String AESPW = Convert.ToBase64String(Key.DataToAes(Encoding.UTF8.GetBytes(pwBox.Text), _key)); //비밀번호 변경 String postRoomLogin = String.Format("userID={0}&roomID={1}&PW={2}", UserInfo.userId, idBox.Text, AESPW); Encoding encoding = Encoding.UTF8; byte[] resultRoomLogin = encoding.GetBytes(postRoomLogin.ToString()); wReqRoomLogin = (HttpWebRequest)WebRequest.Create(url); wReqRoomLogin.Method = "POST"; wReqRoomLogin.ContentType = "application/x-www-form-urlencoded"; wReqRoomLogin.ContentLength = resultRoomLogin.Length; PostDataStreamRoomLogin = wReqRoomLogin.GetRequestStream(); PostDataStreamRoomLogin.Write(resultRoomLogin, 0, resultRoomLogin.Length); PostDataStreamRoomLogin.Close(); wRespRoomLogin = (HttpWebResponse)wReqRoomLogin.GetResponse(); respPostStreamRoomLogin = wRespRoomLogin.GetResponseStream(); readerPostRoomLogin = new StreamReader(respPostStreamRoomLogin, Encoding.UTF8); String resultPostRoomLogin = readerPostRoomLogin.ReadToEnd(); if (resultPostRoomLogin.Equals("1")) { try { File.WriteAllBytes(System.IO.Directory.GetCurrentDirectory() + "/" + roomId + "_PK.scf", _key); } catch { } try { folderPath = File.ReadAllText(System.IO.Directory.GetCurrentDirectory() + "/" + roomId); if (!Directory.Exists(folderPath)) { throw new System.ArgumentException("Path doesn't exist", "original"); } } catch { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.RootFolder = Environment.SpecialFolder.Desktop; fbd.Description = "공유 폴더 경로 설정"; fbd.ShowNewFolderButton = false; if (fbd.ShowDialog() == DialogResult.OK) { folderPath = fbd.SelectedPath; File.WriteAllText(System.IO.Directory.GetCurrentDirectory() + "/" + roomId, folderPath); } else { return; } } newfileLocation = folderPath.Replace(@"\", @"/"); chatform = new Chat_Form(mainform, num); Chat_Form.cloudDirPath = newfileLocation; Chat_Form.cloudDirPath = newfileLocation + "/"; chatform.RoomNameProp = roomId; chatform.Show(); mainform.Hide(); this.Dispose(); } else if (resultPostRoomLogin.Equals("-1")) { MessageBox.Show("등록되지않은 사용자입니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("비밀번호 또는 키파일이 맞지않습니다. ", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }