Visual C++ :: Getting Name Of Current Save File?
Oct 10, 2014When I have loaded a savefile with Serialize, is there some way of telling the name of the currently loaded savefile?
View 2 RepliesWhen I have loaded a savefile with Serialize, is there some way of telling the name of the currently loaded savefile?
View 2 RepliesI am trying to develop a GUI using MFC, but I am having trouble using CFiledialog to save a file. The problem is, the file is not getting saved to the folder when I use the CFiledialog. Below is the code I am using.
Code:
CString szFilter = "XNRep Files (*.xnrep)|*.xnrep||";
CString s = "xnrep";
CString t = "";
CFileDialog fileDlg(FALSE, s, t, NULL, szFilter);
if(fileDlg.DoModal() == IDOK)
{
std::ofstream file;
[Code]....
After the file dialog opens up, I enter the name of the file and select OK button. But the file does not show up in the directory I am saving to.
I am trying to use to save the current date and time into a char array using this code:
char current_time(char *date){
time_t result = time(NULL);
date = ctime(&result);
return *date;
}
main{
[Code]...
now when I output the date char array into a txt file I only get gibberish.
I tried to do this with _spawnl(), but first of all I'm not sure how to properly ask for the path to iexplore.exe, as I'm sure it will change every time MS gets a whim to move it. I know there's a GetWindowsDirectory() call, but that's not where IE resides (its in "C:Program FilesInternet Exploreriexplore.exe" in XP, Lord know where on win 7 or 8).
Also, even temporarily hard coding the path to make it launch with spawnl(), I can't seem to get my html document to display. I know the path to that is right (since I put it there ).
char * pFile = "someFile.htm";
char * pCmd = "C:Program FilesInternet Exploreriexplore.exe";
int res = _spawnl(_P_NOWAIT, pCmd,pCmd, pFile, NULL); // also tried without specifying pCmd 2x
if (res == -1) MessageBox("Can't Open File.");
So my second question would be, how to you PROPERLY pass the file to view as an argument.
I have this code, where I capture window and make copy to bitmap of it. I am working on rotation of bitmap. But my problem is that when I save the image to file the result is just a black screen. It looks like there could be some problem either in GdipCreateBitmapFromHBITMAP() or GdipGetImageGraphicsContext()
How to fix it and to get the rotated image?
Code:
// CODE 81 and 82 de facto no difference
#defineCODE85 // 81
#defineWINDOW_MIN_HEIGHT200
[Code].....
I am overriding OnSaveDocument in my MFC document class to strip out the carriage returns when saving my app's document to a UNIX file system but not when the user is saving a file to a Windows file system.
Is there a way to determine if the lpszPathName in OnSaveDocument(LPCTSTR lpszPathName) is a UNIX or Windows file system?
Note, I want to avoid hard coding server names and I want to avoid overriding the FileSave dialog and forcing the user to select Windows or UNIX.
I have a MAPI session that is loged on and valid, I would like to get the current logged on profile string from it.
View 2 Replies View RelatedI quite often use an ide written in assembler: RadAsm3[URL] .....
It has a menu item to explore current path. I have used other ide's that have a similar feature but:
The one in RadAsm3 will activate a current Explorer window if the current path is the same as the one requested.
All others open a new Explorer window.
I would like to implement the RadAsm3 approach using Visual Studio 2013 Community c++ as my host compiler for testing.
I tried to get the title of current windows but it appears ShellExecute "explore" does not produce a conventional window???
I created two split views like this:
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext ) {
CFrameWnd::OnCreateClient(lpcs, pContext);
if (!m_wndSplitter.CreateStatic (this, 2, 1) ||
[Code]....
When I step into CMainFrame::OnAlohaHowAreYou(), I found m_pDoc is NULL. If I remove the split views and make CMainFrame::OnCreateClient() like below, then there is no problem.
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext ) {
CFrameWnd::OnCreateClient(lpcs, pContext);
return TRUE;
}
i have to write the current time to a file ?how to do it
View 2 Replies View RelatedI have tried to use File.Copy and File.Move but non of them would work as I expected .....
View 1 Replies View RelatedI have tried everything I can think of to get rid of the 'Save changes to Untitled?' message box that appears every time my SDI split app tries to load a new file. The problem is that the message appears inappropriately, both when no previous document has been loaded or should exist, and even after File / New has been envoked. I have attached a small demo program to demo the problem. Inspecting the SpVwTrDoc.cpp NewDocument and OnOpenDocument, and elsewhere, you will see that using SetModifiedFlag(FALSE); has no effect.
View 10 Replies View RelatedHow can I save an CDocument programatically, without to bring him to the top, only if I get a pointer to that document ? I mean if I have several document opened into a MDI app, and if I have a pointer to one of them, to save it without to turn them as active childs ?
View 3 Replies View Related1st when i fill the things on form then saved in database after saving record when i want add another record it shows an error. after saving it saves new record refresh doesn't work
View 1 Replies View RelatedI'm having a little problem with std:fstream - in my program, the user selects the location of a file which I want to remember. So, I have something like this:
Code: std::string fileLocation;
//Code here creates an 'open file' dialog box which lets the user choose which file to open.
//The string 'fileLocation' now contains the path to the chosen file.
std::ofstream prefs("prefs.txt");
if (prefs.is_open())
{
prefs << fileLocation;
prefs.close();
}
This works fine if the file chosen is in the same directory as the program, however, if they try to choose a directory outside of where the program is kept, it saves the text file into that directory instead of the same one as the program. So, it looks like outputting a directory into an ofstream actually changes the location to which the file is saved.
Is there a way to save the file directory to a text file using ofstream and still have the text file save in the same directory as the program?
How do you create a save file for a game, that is not a separate file? Specifically I am using code::blocks and sfml 2.1 to make a game and it saves to a text file at the moment. My problem is that it is very easy to modify the text file, and it is annoying to have to copy and paste several files if you want to use a copy of the game. I have a feeling that it may be to do with resource files, but I'm not exactly sure how to get these to work or whether you can modify them dynamically.
View 6 Replies View RelatedHow to save the struct to file and then read it back from the file ?
Code:
#include <conio.h>
#include <stdio.h>
struct student {
int person;
int egn;
float AvergeGrade;
[Code] ....
Have average grade: %f", person[i].FirstName, person[i].LastName, person[i].egn, person[i].AvergeGrade);
}
//Save to file
getch ();
}
what are the codes that will save the data then it will appear in a file (.txt).
I typed the name "SpongeBob SquarePants"
SpongeBob SquarePants
I am creating a program using the inheritance. The superclass is person and subclass is employee,manager etc. I will prompt the user to choose which subclass he want to save the record to but i dont know how to write and display the record of different subclass to and from a txt file.
View 4 Replies View RelatedI've been trying to figure out how to implement a way to save this board state throughout a user's inputted path. At the end, I need the output to print out the board states (user's path) of how he or she got the puzzle solved. This puzzle is the 15 Puzzle; but we have it to change by the user's input on what size they want to play (3x3 to 5x5). How to save the board state of each user input, then print those out in order from beginning to solved puzzle state. Subsequently, I would also need transferring the board state to change with using a vector to store the size based on user input. How to proceed, using a first search to solve the puzzle from the current board's state.
calculations.h
Code:
/*Calculations set as a header to keep compiling simple and faster*/
#ifndef calculations
#define calculations
int solved[5][5];
void initialize(int board[][5], int);
void slide(int board[][5],int move,int);
bool isBoardSolved(int board[][5],int);
[Code] .....
Code:
struct sth {
char* str;
} pt;
}
[code]...
fprintf does not save string to file. How can I put structure into list?
I have a 4*4 array and a 8*8 arays in my c++ program and i would like to save those arrays in one textfile. How do i do that.
View 5 Replies View Relatedi tried to dave my datagridview to a binary file it worked at first and then when i tried it again it said file is being used by another process.
this is the code that loads the binary file
:
public void loadingparty()
{
string file = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\mygrid.bin";
if (File.Exists(file))
[Code].....
I'm trying to save a structure to a binary file, then read it out of the binary file into a new structure. I am unsure what is happening but it is not correct.
#include <iostream>
#include <fstream>
using namespace std;
[Code]....
I tried to save some data from my listbox to the text file, but didn't work... I think I tried many combination for code but still didn't work. what to do?
FileStream fs = new FileStream("tx.txt", FileMode.Create);
StreamWriter sr = new StreamWriter(fs);
sr.Write(listBox1.Text); //there is that problem, but I'm not sure how to write for success
sr.Close();
Opening large files in c++. In my application, i am trying to save video as long as users have space in harddisk. What I am trying to do is when user is recording video i am trying to append the video data in to the file. The problem is that every time file size reach over 2GB my software crashes.
View 5 Replies View Related