delphi4arab منتديات دلفي للعرب
كيف احظر جميع اسماء الملفات للتحقق من ان الاسم لا يوجد مسبقا - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15)
+--- الموضوع : كيف احظر جميع اسماء الملفات للتحقق من ان الاسم لا يوجد مسبقا (/showthread.php?tid=12168)



كيف احظر جميع اسماء الملفات للتحقق من ان الاسم لا يوجد مسبقا - Med-01 - 26-12-2022

السلام عليكم لدي مجلد به ملفات لانشاء ملف جديد اخد نسخة من اي ملف واغير اسمه فيتم انشاء ملف جديد باسم جديد المطلوب هو عمل تحقق انو اسم الملف غير موجد لاظهار رسالة انو الملف بهذا الاسم موجود مسبقا غير الى اسم اخر انا استخدم FileListBox1 لعرض الملفات الموجودة في المجلد
PHP كود :
if(edit1.Text='')then showmessage('empty !') else CopyFile('model.mdb',PChar(Edit1.Text+'.mdb'),false); FileListBox1.Update 

<img title="Angel" alt="Angel" data-sceditor-emoticon="Angel" src="https://delphi4arab.net/forum/images/smilies/angel.png"> <p><br></p>


RE: كيف احظر جميع اسماء الملفات للتحقق من ان الاسم لا يوجد مسبقا - larbiparadox - 27-12-2022

وعليك الاسلام ، رد سريع في إحتمال أخطاء

كود :
         if(edit1.Text='') then begin         showmessage('empty !');         Abort;       End;        if FileExists(FileListBox1.Directory+Edit1.Text+'.mdb')  then  begin             showmessage('il''est existe déjà !!');                     end else begin              CopyFile(FileListBox1.Directory+'model.mdb',PChar(FileListBox1.Directory+Edit1.Text+'.mdb'),false);               FileListBox1.Update;          END;



RE: كيف احظر جميع اسماء الملفات للتحقق من ان الاسم لا يوجد مسبقا - Med-01 - 27-12-2022

<p>لم يعمل الكود مع اني صححته لايوجد خطا لاكن لا يعمل<br><br>
PHP كود :
procedure TForm1.Button5Click(Sender: TObject);
begin
         
if(edit1.Text='') then begin
        showmessage
('empty !');
        
Abort;
      
End;
       if 
FileExists(FileListBox1.Directory+Edit1.Text+'.mdb')  then  begin
            showmessage
('il''est existe déjà !!');

          
end else begin
             CopyFile
(PChar(FileListBox1.Directory+'model.mdb'),PChar(FileListBox1.Directory+Edit1.Text+'.mdb'),false);
            
// CopyFile('model.mdb',PChar(Edit1.Text+'.mdb'),false);
              
FileListBox1.Update;
         
END;
end;

end. 
<br></p>


RE: كيف احظر جميع اسماء الملفات للتحقق من ان الاسم لا يوجد مسبقا - larbiparadox - 28-12-2022

الكود الصحيح
كود :
if edit1.Text = '' then begin showmessage('empty !'); Abort; End; if FileExists(PChar(FileListBox1.Directory+'\'+Edit1.Text+'.mdb')) then begin showmessage('il''est existe déjà !!'); end else begin CopyFile(PChar(FileListBox1.Directory+'\'+'Unit1.dcu'),PChar(FileListBox1.Directory+'\'+Edit1.Text+'.mdb'),True); // CopyFile('model.mdb',PChar(Edit1.Text+'.mdb'),false); FileListBox1.Update; END;



RE: كيف احظر جميع اسماء الملفات للتحقق من ان الاسم لا يوجد مسبقا - Med-01 - 28-12-2022

<p>
(28-12-2022, 08:57 AM)larbiparadox كتب : الكود الصحيح
كود :
if edit1.Text = '' then begin showmessage('empty&nbsp;!'); Abort; End; if FileExists(PChar(FileListBox1.Directory+'\'+Edit1.Text+'.mdb')) then begin showmessage('il''est&nbsp;existe&nbsp;déjà&nbsp;!!'); end else begin CopyFile(PChar(FileListBox1.Directory+'\'+'Unit1.dcu'),PChar(FileListBox1.Directory+'\'+Edit1.Text+'.mdb'),True); //&nbsp;CopyFile('model.mdb',PChar(Edit1.Text+'.mdb'),false); FileListBox1.Update; END;
<br><br>جزاك الله خيراا بارك الله فيك في ميزان حسناتك انشاء الله&nbsp;</p>