1. delphi 如何在指定目錄下創建文件
the method is so more. such as following,
var
list : TStringlist;
begin
list := TStringlist.Create;
list.DelimitedText := '1900-11-16';
list.SaveToFile('F:\test.txt'); //create text file in disk F:
list.Free;
end;
2. 如何用DELPHI創建一個文件夾和一個文本文件
創建文件:
CreateFile(FileName, fmCreate,)
創建文件夾:
ForceDirectiory
幫助裡面有這兩個函數的詳細說明。
3. delphi 怎麼新建文件
同意樓上的,有點筆誤
myinifile.redainteger('小節名','關鍵字','預設值');//讀取整數型數據。
應為
myinifile.readinteger('小節名','關鍵字','預設值');//讀取整數型數據
創建一個文件的函數:
function FileCreate(const FileName: string): Integer;
Description
FileCreate creates a new file with the specified name. If the return value is positive, the function was successful and the value is the file handle of the new file. A return value of -1 indicates that an error occurred.
4. delphi的文件操作,比如創建一個文件是怎樣操作的(只創建一個空文件)
var
filename:string;
FHandle:integer;
begin
filename:='e:\database.txt';
if(not fileexists(filename))then
begin
FHandle:=filecreate(filename);
end;
5. Delphi 7創建文件夾的問題
DateToStr()返回的字元串格式跟系統的日期分隔符有關,只有當系統的日期分隔符是「-」和「.」時,用返回回的字元串通過答ForceDirectories()創建文件夾才會成功。系統的日期分隔符是「/」時是不行的。 在XP下也一樣。系統的日期分隔符在用資源管理器瀏覽文件的「詳細信息」視圖下就看得出來。
6. 怎麼用delphi建立一個文件夾
給你個函數吧
/*******************************************************************************
* 建立文件夾路徑函數 *
*******************************************************************************/
int SearchStr(CString Source,char SearChar,int Howth) //搜索匹配的字元位置
{
int HowBit;
HowBit = Howth;
int len = strlen(Source);
for (int i = HowBit;i <len;i++)
{
if (Source[i] == SearChar)
{
return i;
break;
}
}
return -1 ;
}
/*******************************************************************************
* 建立文件夾 *
*******************************************************************************/
void CreatePath(CString Path)
{
int SearSult = SearchStr(Path, ': ',1);
CString a;
CString Pathstr;
int len = strlen(Path);
while(SearSult != -1)
{
SearSult = SearchStr(Path, '\\ ',SearSult+3);
if(SearSult!=-1)
{
Pathstr = Path.Left(SearSult);
if(_access(Pathstr,0)!=0)
CreateDirectory(Pathstr,0);
}
else
break;
}
if(Path[len-1]!= '\\ ')
{
if(_access(Path,0)!=0)
CreateDirectory(Path,0);
}
}
7. delphi中CreateDirectory和CreateDir有什麼區別創建文件夾的同時能定義文件夾的屬性嗎
CreateDir也是通過調用CreateDirectory實現的,只是簡化了參數,並且增加了linux支持。
CreateDirectory只能用於回windows編程。CreateDir在linux下Kylix也能調用,答使代碼的兼容性、可移植性更強。
在SysUtils單元中:
function CreateDir(const Dir: string): Boolean;
begin
{$IFDEF MSWINDOWS}
Result := CreateDirectory(PChar(Dir), nil);
{$ENDIF}
{$IFDEF LINUX}
Result := __mkdir(PChar(Dir), mode_t(-1)) = 0;
{$ENDIF}
end;
8. 我想在DELPHI 中在本機PROGRAM FILES 文件夾下建立一個目錄123
var
adr:array[0..MAX_PATH] of Char;
begin
GetSystemDirectory(adr,MAX_PATH);
end;
adr裡面就是你想要的路徑,然後在去創建目錄去。
9. delphi怎麼創建以當前日期命名的文件夾
CreateDirectory( PChar( 'C:\' + FormatDateTime( 'yyyymmdd', Now ) );
10. delphi 如何創建文件夾
forcedirectories和CreateDirectory都能創建文件 ForceDirectories可以創建多層目錄. 如果你創建一個目錄為c:\mymusic\music 如果你的C盤不存在一個叫mymusic的文件夾 的話程序會自動創建,函數執行的結果是, 創建了兩個文件夾,mymusic和music,music為 mymusic的子文件夾. CreateDirectory只能創建一個文件夾,如果 mymusic不存在,則反回創建music文件夾失敗! procere TMain.WriteVPTXT(str:string);varMytextFile : TextFile; tempstr : string; SysTime: TsystemTime;begintryGetLocalTime(SysTime); //AssignFile(MyTextFile,'D:\delphi\delphitest\time.ini'); if not DirectoryExists('D:\Test') then CreateDirectory('D:\Test',nil); //創建單個目錄 // forcedirectories ('D:\Test'); //創建多層目錄 tempstr:='D:\Test\'+inttostr(Systime.wYear)+inttostr(systime.wMonth)+inttostr(systime.wDay)+'.txt'; AssignFile(MyTextFile,tempstr); if not fileExists(tempstr) then ReWrite(MyTextFile) else Append(MyTextFile);