• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Load a txt file using UNC

Ok thanks for helping me with the text file question I had. Now I have another little problem. I have this code here
//...
BOOL CWarningMessageDlg::OnInitDialog()
{
      CDialog::OnInitDialog();
//...
      CFile file;
    file.Open("C:\\Warning.txt",CFile::modeRead);
    int n = file.GetLength();
    char * pzsBuf = new char[n];
    file.Read(pzsBuf,n);
    m_Message = pzsBuf;
    UpdateData(FALSE);
//...


My questions is how can I loaded a text file that's on a network path using UNC? Instead of C:\Warning.txt I want to use \\server\folder\Warning.txt
0
fredmastro
Asked:
fredmastro
  • 5
  • 4
  • 3
1 Solution
 
jhanceCommented:
Where you have:

C:\\Warning.txt

replace it with:

\\\\server\\folder\\Warning.txt

if the network path is valid, then it will work.
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

No Prob

file.Open("\\\\server\\folder\\Warning.txt",CFile::modeRead);

will solve Ur prob.

Try it out.
VinExpert
0
 
jhanceCommented:
VinExpert,

Thanks for stealing my answer!!
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
gvgCommented:
Hi,

If the folder isn't shared you can use the drive letter C$ for example.

file.Open( "\\\\MyServer\\C$\\Folder\\Warning.txt", CFile::modeRead );

Note: If you have a shared server drive that you have mapped for example as h: on you computer you can get the UNC by using the function WNetGetUniversalName.  It would translate H:\Warning.txt to \\MyServer\C$\Folder\Warning.txt

Gunnar Valur.
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi jhance,

U R welcome, better luck next time!!!(:-))

VinExpert
0
 
jhanceCommented:
Well at least it shows you can read.  

If the best way you can find to get points is to steal other people's answers, then I guess I should be honored that you think mine are good enough to rip off....
0
 
gvgCommented:
Just one question jhance

Why didn't you put it as a answer instead of a comment since it is the answer?
0
 
jhanceCommented:
Just a coutesy to the asker.  If it's locked with an answer, it no longer show up in the available questions.  The staff at EE has been encouraging experts to post comments and let the owner of the question choose the right one as an anwser.  In fact, they are considering removing the ANSWER choice altogether.  I've been trying to use this method recently but experts like the one above are one of the reasons why this courtesy won't work.
0
 
gvgCommented:
I agree with you.  Answers should be removed. I hope fredmastro gives you the points since you were first.
 
0
 
jhanceCommented:
Thanks fredmastro, you're a real pal!  

You gave the credit where credit was NOT due!
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi jhance,

I never meant to heart U.(sorry if it is the case.) But I posted it as an answer without seeing Ur comment.(We did it almost the same time.) So no question of getting the points by stealing others answers. I too put the answers as comments if I am not 100% sure of the case. That I think almost all experts do. If U think u should get points, then no prob, fredmastro can ask EE to settle it. So peace... Ok(thanks and sorry if my comment has hearted U).

Regards,

VinExpert
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

Replace all 'heart' with 'hurt'.

:-)

VinExpert
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now