Problems opening a text file

I have a simple code written in Delphi XE8 that creates a simple text file named 'NE25_000.txt' in the folder 'C:\GiST_XE8\CM\NE25\NE25_000\'. When I wrote another simple code that opens this file, the file doesn't exist. 
When I move the file to folder ''C:\GiST_XE8\' the code recognize the file. If I begin adding subfolders, it doesn't recognize the file (e.g.  'C:\GiST_XE8\CM\'). I created the file in another disk ('D:') using the same path: 'D:\GiST_XE8\CM\NE25\NE25_000\' and the file is not recognized. I also tried other shorter paths and only works when using 'D:\GiST_XE8\'
I removed my 'Norton Smart Firewall' and 'Norton Auto Protect' and it doesn't work. I'm running Windows 7 Professional. Can somebody help me to solve this headache? Here is the code:

var

WSFileNames                           : Textfile;
tempStr,linea                             : String;

begin

   tempStr:= 'C:\GiST_XE8\CM\NE25\NE25_000\NE25_000.txt'; 

   If FileExists(tempStr) then
      Begin
      Assignfile(WSFileNames,tempStr);
      Reset(WSFileNames);
      Readln(WSFileNames,linea);
     .....
      end;
0
Consuelo
7/23/2015 11:23:24 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

1 Replies
947 Views

Similar Articles

[PageSpeed] 24
Get it on Google Play
Get it on Apple App Store

Consuelo wrote:

> I have a simple code written in Delphi XE8 that creates a simple text
> file named 'NE25_000.txt' in the folder
> 'C:\GiST_XE8\CM\NE25\NE25_000\'. When I wrote another simple code
> that opens this file, the file doesn't exist.

Did you verify that the file really does exist on the disk, and is not being 
used by anything else (like an AntiVirus)?  Have you tried using SysInternals 
Process Explorer/Monitor, or similar tools, to monitor the disk activity 
on your file and see what is really happening?

> I removed my 'Norton Smart Firewall' and 'Norton Auto Protect' and
> it doesn't work. I'm running Windows 7 Professional.

Did you remove Windows Defender?

> Here is the code:

Why are you using outdated Pascal File I/O, instead of something more modern, 
like TStringList, TFileStream, or TStreamReader?

In any case, I would not bother checking FileExists() in this case.  It can 
report an incorrect result at times.  A better option is to just let Reset() 
fail if the file cannot be opened.  You can check IOResult to see if Reset() 
is successful:

{code}
var
  WSFileNames: Textfile;
  tempStr, linea: String;
begin
  tempStr := 'C:\GiST_XE8\CM\NE25\NE25_000\NE25_000.txt';

  AssignFile(WSFileNames, tempStr);
  Reset(WSFileNames);
  if IOResult = 0 then
  begin
    Readln(WSFileNames, linea);
    if IOResult = 0 then
    begin
      ...
    end else
    begin
      // error, do something ...
    end;
    CloseFile(WSFileNames);
  end else 
  begin
    // error, do something ...
  end;
end;
{code}

Or you can enable the {$I+} directive (input/output checking) so an exception 
is raised on I/O failures:

{code}
var
  WSFileNames: Textfile;
  tempStr, linea: String;
begin
  tempStr := 'C:\GiST_XE8\CM\NE25\NE25_000\NE25_000.txt';

  AssignFile(WSFileNames, tempStr);
  try
    Reset(WSFileNames);
    try
      Readln(WSFileNames, linea);
      ...
    finally
      CloseFile(WSFileNames);
    end;
  except
    on E: EInOutError do begin
      // error, do something ...
    end;
  end;
end;
{code}

-- 
Remy Lebeau (TeamB)
0
Remy
7/23/2015 11:57:00 PM
Reply:

Similar Artilces:

Problem opening files "too many files open"
I have a Netware 6.0 SP4 server with about 20 Windows XP clients. I am connecting to the server using CIFS. I get an error message about "too many files open" when trying to access files. can anyone tell me how to fix this. Could the following apply to your problem? http://support.novell.com/cgi-bin/search/searchtid.cgi?10093040.htm -- Marcel Cox (using XanaNews 1.17.5.9) thanks for the info. it seems that my conditon has something in common with the technote. I am trying to sign into the server on all 22 machines with the same NFAP user id. i didn;t f...

ANSI text file convert to Unicode text file problem
Dear all, I got a problem from my PB 7.03 ANSI version. I need to write a program to convert a ANSI text file to Unicode text file. I had been tried to use the FromANSI, toANSI, FromUnicode and ToUnicode PB function to do that. Since those functions for convert the ANSI file to Unicode file also Unicode file to ANSI file it seem working well. However, when I try to open the Unicode file (which is convert from ANSI to Unicode format by PB function) from my Wordpad, It will show me the result was fail... So now I have a question... As I know the Unicode have different type (eg. UTF-...

superreview requested: [Bug 294019] File opened with File->Open always loads in the first tab : [Attachment 188049] Proposed patch fixes problem
Nick Kreeger <nick.kreeger@gmail.com> has asked Mike Pinkerton <pinkerton@aol.net> for superreview: Bug 294019: File opened with File->Open always loads in the first tab https://bugzilla.mozilla.org/show_bug.cgi?id=294019 Attachment 188049: Proposed patch fixes problem https://bugzilla.mozilla.org/attachment.cgi?id=188049&action=edit ------- Additional Comments from Nick Kreeger <nick.kreeger@gmail.com> I modified the method: - (void)openURLArray:(NSArray*)urlArray replaceExistingTabs:(BOOL)replaceExisting allowPopups:(BOOL)inAllowPopups Just replace wi...

superreview cancelled: [Bug 294019] File opened with File->Open always loads in the first tab : [Attachment 188049] Proposed patch fixes problem
Simon Fraser <sfraser_bugs@smfr.org> has cancelled Nick Kreeger <nick.kreeger@gmail.com>'s request for superreview: Bug 294019: File opened with File->Open always loads in the first tab https://bugzilla.mozilla.org/show_bug.cgi?id=294019 Attachment 188049: Proposed patch fixes problem https://bugzilla.mozilla.org/attachment.cgi?id=188049&action=edit ...

Opening file...replace text...close file
HI, I'm new to this list. I would like to know how I can open an existing file on the server (windows). Search for some text and once found replace it with something else and then save/close the file. Thanks --------------------------------------------------- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba --------------------------------------------------- FlashGuy wrote: >HI, > >I'm new to this list. I would like to know how I can open an existing file on the server (windows). Search for some text and ...

Text Formatting Problem in MultiLine Text And Reading from File
Hi, I am reading text and .cs files. And displaying them in a multiline TextBox. It works nice but when the file is loaded in .cs file then it all messed up and out of order. everything is too compact. anyidea how to solve itHighOnCodingWanna get high! solved. Had to use Environment.NewLine();HighOnCodingWanna get high! ...

superreview requested: [Bug 363654] .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch : [Attachment 248458] disables .url in file:open
Smokey Ardisson (unreliable; no bugmail) <alqahira@ardisson.org> has asked Stuart Morgan <stuart.morgan@alumni.case.edu> for superreview: Bug 363654: .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch https://bugzilla.mozilla.org/show_bug.cgi?id=363654 Attachment 248458: disables .url in file:open https://bugzilla.mozilla.org/attachment.cgi?id=248458&action=edit ------- Additional Comments from Smokey Ardisson (unreliable; no bugmail) <alqahira@ardisson.org> Asking for sr on this 7-char patch in case we need to take it ...

superreview granted: [Bug 363654] .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch : [Attachment 248458] disables .url in file:open
Stuart Morgan <stuart.morgan@alumni.case.edu> has granted Smokey Ardisson (unreliable; no bugmail) <alqahira@ardisson.org>'s request for superreview: Bug 363654: .url files opened via File:Open don't open/don't open properly on the 1.8.0 branch https://bugzilla.mozilla.org/show_bug.cgi?id=363654 Attachment 248458: disables .url in file:open https://bugzilla.mozilla.org/attachment.cgi?id=248458&action=edit ------- Additional Comments from Stuart Morgan <stuart.morgan@alumni.case.edu> Well, that kinda sucks. ...

Problems saving excel files and opening word files with cifs
I have a NW6SP4 cluster with cifs. Users can access shares but they are not able to open word files nor saving excel files (word and excel simply stuck!). It doesn't ahppens with other kind of files (text only, power point, acess databases). I guess it has something to do with the way excel and world work with files (using temporary files). I tried to apply the latest cifs patches available for nw6 (cifs.nlm 1.60 oct 5 2004), but it didn't solve the problem. I'm using word and excel 2000. Can someone help me ? Thanks in davance. You're having this problem when...

Open file(text,word,etc) file using fileupload control
hi in my project i want to open my file in my project,in click event i want to open file and file path is fileupload control's text box path,how can i do that example like fileupload.open(filepath) that open my file waiting for replay thanksNothing is really over,untill the moment stop trying for it...Amitsp(MCTS,MCP)sqlreporting.blogspot.com...

Access is denied: Cannot open aspx page, but can open text file
I'm not sure this is the proper place to post, so please let me know if I should post it elsewhere.  I have an ASP.NET 1.1 application that will not work on a client's machine.  Specifically, I can not get a simple aspx page to run on the machine.  It is a Windows 2000 with SP4 and has ASP.NET 1.1 installed.   I CAN access a sample text page through the same web directory.  In researching the issue, I found the following article that describes my situation almost exactly - EXCEPT that this is not a domain controller and I don't seem to have the domain contr...

Open File problem.
Hello, I am noticing a memory loss in an application that I have written, the application opens 50 different "text" files (that are formatted with internal tags) and creates roughly 7-8000 .html pages. In the following function (rewritten with memavl for testing purposes) I receive an arguement that is the file name of the page I just created and add it to an "IndexPage". The memory loss from just this code is very large. Where am I going wrong??? Should I not use: fopen, fputs & fclose??? If not what should I use, I have tried open, write & close, th...

problem opening files
Grettings, sometimes when you try to open some files do not open, I have to right click and select open with ... and so if they are opened but not directly, this happens with files .doc,.txt ..... Thanks you. -- jony127 ------------------------------------------------------------------------ Which desktop environment (GNOME, KDE3/4, XFCE, LXDE...) do you use? By "sometimes" do you mean a *certain* file can be opened by clicking it one day and can not the other day or do for example .txt-files generally not work? -- gropiuskalle -------------------...

File opening problem
------=_Part_896_24842907.1210597554319 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all! i'm running the following dummy program which just opens a file and I get an error (die message) #!/usr/bin/perl if ( @ARGV[0] eq '' ) { print "\nUSAGE:\n\t genenames.pl genes.txt \n\n"; exit; } my $file = $ARGV[0]; open(FICH,"$file") or die "cannot open $file"; I've tried to pass the input parameter ARGV[0] with / with \ with relative path ... but nothing ...

Web resources about - Problems opening a text file - embarcadero.delphi.general

Is–ought problem - Wikipedia, the free encyclopedia
The is–ought problem in meta-ethics as articulated by Scottish philosopher and historian David Hume (1711–76) is that many writers make claims ...

Surprise! Lawyers Are Problem Drinkers
Assuming there are 10 attorneys on your team, statistically, two to three of the attorneys are suffering from drinking problems, depression, ...

This 1-minute visualization on space junk reveals a serious problem
... will completely obliterate a satellite and turn it into hundreds of smaller pieces. As you can imagine, this only exacerbates the problem because, ...

Ben Carson has a problem with Bill Clinton's history with women
GOP hopeful blames former President Clinton for coarsening American children

Engine problem sends Virginia-bound plane back to New York
... shortly after takeoff. A spokesman for the FAA says the crew of Commutair Flight 3585 declared an emergency because of an "engine-related problem" ...

Top 11 Problems Plaguing Solar And Wind Power
Wind and solar power will have to resolve these 11 fundamental issues before they can "fix" global warming.

Thanks, Obama. Fewer people have problems paying medical bills.
... In the first half of 2011 through the first half of 2014, approximately one in five persons under age 65 was in a family that had problems ...

Spotify pledges to fix the music industry's royalty problems
Paying artists for streams isn't just Spotify's problem the whole industry is stuck with a royalty model that's better suited for physical sales ...

The Displacement Problem
A problem with gentrification-led involuntary displacement is that makes it being poor even more unaffordable by pricing people out of areas ...

Major League Baseball's Biggest Problems
Major League Baseball may never be healthier than it is now, but that doesn't mean it's flawless. Here's some key problems the league needs to ...

Resources last updated: 12/29/2015 7:37:48 PM