Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. fstream

fstream

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++help
4 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krauftig
    wrote on last edited by
    #1

    I am trying to write a managed C++ extension to be used with a project I am working on. All seems to work well except that .NET seems to refuse to recognize any fstream members, and I can't instantiate it. I include it in the stdafx.h. Any help would be greatly appreciated.

    N 1 Reply Last reply
    0
    • K krauftig

      I am trying to write a managed C++ extension to be used with a project I am working on. All seems to work well except that .NET seems to refuse to recognize any fstream members, and I can't instantiate it. I include it in the stdafx.h. Any help would be greatly appreciated.

      N Offline
      N Offline
      Nick Hodapp
      wrote on last edited by
      #2

      This should work fine - in my simple test I #include <fstream>, then instantiate a fstream object. The types defined in fstream are in the std namespace. Does your code reflect this?

      #include "stdafx.h"

      #using #include #include using namespace System;

      // This is the entry point for this application
      int _tmain(void)
      {
      std::fstream fs;
      fs.open("filename");

      // TODO: Please replace the sample code below with your own.
      Console::WriteLine(S"Hello World");
      return 0;
      

      }

      This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2002 Microsoft Corporation. All rights reserved.

      A 1 Reply Last reply
      0
      • N Nick Hodapp

        This should work fine - in my simple test I #include <fstream>, then instantiate a fstream object. The types defined in fstream are in the std namespace. Does your code reflect this?

        #include "stdafx.h"

        #using #include #include using namespace System;

        // This is the entry point for this application
        int _tmain(void)
        {
        std::fstream fs;
        fs.open("filename");

        // TODO: Please replace the sample code below with your own.
        Console::WriteLine(S"Hello World");
        return 0;
        

        }

        This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2002 Microsoft Corporation. All rights reserved.

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Your code seems to work however, I am unsure of what file for the #using, I have tried the name of the built .dll in my case Test.dll, but I get the error "Could not find assembly Test.dll". Also if I include no filename, it expects one. I am new to Visual C++ .NET Managed Forums, and I would like to thank you for your patience.

        N 1 Reply Last reply
        0
        • A Anonymous

          Your code seems to work however, I am unsure of what file for the #using, I have tried the name of the built .dll in my case Test.dll, but I get the error "Could not find assembly Test.dll". Also if I include no filename, it expects one. I am new to Visual C++ .NET Managed Forums, and I would like to thank you for your patience.

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          Anonymous wrote: I am unsure of what file for the #using Nick didn't format it (;P), the following will need to be included for the source to work:

          #include "stdafx.h"
          #using <mscorlib.dll>
          #include <tchar.h>
          #include <fstream>
          using namespace System;

          Nick Parker
          May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups