C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[63079] Re:파일 입출력 질문입니다.
크레브 [kkol] 1218 읽음    2010-11-23 23:00
Help 찾아보시면 다  나옵니다.


RenameFile

Changes a file name.

Unit

SysUtils

Category

file management routines

extern PACKAGE bool __fastcall RenameFile(const AnsiString OldName, const AnsiString NewName);

Description

RenameFile attempts to change the name of the file specified by OldFile to NewFile. If the operation succeeds, RenameFile returns true. If RenameFile cannot rename the file (for example, if the application does not have permission to modify the file), it returns false.


#include 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  char szFileName[MAXFILE+4];
  int iFileHandle;
  int iLength;
  if (SaveDialog1->Execute())
  {
    if (FileExists(SaveDialog1->FileName))
    {
      fnsplit(SaveDialog1->FileName.c_str(), 0, 0, szFileName, 0);
      strcat(szFileName, ".BAK");
      RenameFile(SaveDialog1->FileName, szFileName);
    }
    iFileHandle = FileCreate(SaveDialog1->FileName);

    // Write out the number of rows and columns in the grid.
    FileWrite(iFileHandle, (char*)&(StringGrid1->ColCount), sizeof(StringGrid1->ColCount));
    FileWrite(iFileHandle, (char*)&(StringGrid1->RowCount), sizeof(StringGrid1->RowCount));
    for (int x=0;xColCount;x++)
    {
      for (int y=0;yRowCount;y++)
      {
        // Write out the length of each string, followed by the string itself.

        iLength = StringGrid1->Cells[x][y].Length();
        FileWrite(iFileHandle, (char*)&iLength, sizeof(iLength));
        FileWrite(iFileHandle, StringGrid1->Cells[x][y].c_str(), StringGrid1->Cells[x][y].Length());
      }
    }
    FileClose(iFileHandle);
  }
}





이재하 님이 쓰신 글 :
: 같은 이름의 파일이나 폴더를 생성할때 기존의 파일이나 폴더의 이름을 바꾸려고 하는데요
:
: 어떤 방법으로 해야 하나요 도와주세요~

+ -

관련 글 리스트
63078 파일 입출력 질문입니다. 이재하 983 2010/11/23
63079     Re:파일 입출력 질문입니다. 크레브 1218 2010/11/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.