Hello fellow programmers, i'm having trouble opening a file from a specific location. Please help. -
#include "maidcafe.h"
-
....
-
char directory[80] = {"C:\\Users\\Public\\Documents\\Anime Notes\\Transaction\\"};
-
char code[20];
-
printf("Enter file name");
-
gets(code);
-
strcat(directory,code);
-
system("start \"\" %s",directory);
-
-
i thought this would work, but it didn't xD. I got an error
3 1703
Usually a file is opened using fopen. - FILE* fp;
-
fp = fopen("C:\\etc...", "w+");
If you're wanting some external program to use your file, then IIRC, system doesn't like the extra quotes and whatnot, so build your command string before calling the function. Use the short path name (the 8.3 notation) or you might try adding quotes around the entire finished path. -
char directory[255] = "start \"c:\\......\\";
-
// make sure directory has enough space
-
-
// get your file name
-
-
strcat(directory, code);
-
strcat(directory, "\"");
-
-
system(directory);
-
Another alternative is to use sprintf -
char cmd[255] = { 0 },
-
directory[80] = "c:\\.....\\",
-
code[20] = { 0 };
-
-
// get required info
-
-
sprintf(cmd, "start \"%s%s\"", directory, code);
-
system(cmd);
-
thanks guys, you really helped me ;)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rob Meade |
last post by:
Hi all,
I was looking this evening for a quick sample of iterating through a text
file to read it in line by line...
I had already thrown something together myself which resembled the example,
but the main difference being that in my code I simply give the stream
reader the path to my file, where as in the example they opened the text
file, held it in an object, then fed that to the stream reader.
|
by: RNDAS |
last post by:
Hi,
I have a DataGrid in my web page and there is a column in that
grid which template column with linkButton. When Clicked the
linkButton it should not refresh the page, rather it should open a
file in notepad. I am not able to resolve it. Can you please help
me with code how to do it? I have spent days after days seraching
Web, books with no luck. I am a newbie in .net.
Thanks a lot
Hope someone would be kind enough to provide me a...
|
by: Jason |
last post by:
Can someoneillustrate how I would open a text file that looks something
similar to this:
namea,8888,1234.99
nameb,8887,1242.50
and then after opening that file read each one of the values into an
array...namea and 8888 and 1234.99 would be three arrays
thanks
|
by: Chris Johnson |
last post by:
I have what seems to be such a simple thing yet I cannot figure out how
to do it.
I am using a streamwriter to build a text file. At the end of the
process I want to open that same text file in notepad so the user can
see what was built.
I cannot for the life of me figure out how to get the text file to open
up in notepad on the screen. All the processes I have tried opens the
file into the filestream again.
|
by: Tony Girgenti |
last post by:
Hello.
I developed a web consuming windows application/form program with VS.NET
2003, VB, .Net Framework 1.1.4322, ASP.NET 1.1.4322, IIS 5.1.
Using this code to open a simple text file. If i get an error in my program
after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."
FileOpen(1, "C:\xmltrips.txt", OpenMode.Output, OpenAccess.Write)
| |
by: emm |
last post by:
Hello, guyz!
I need help on how to open a text file and read it line by line using VB6. What would be the codes?
I have searched the forum and found one but it uses VB.net. :-(
thanks!
|
by: vincec |
last post by:
Hi need some help from you guysin using visual C++. I am thinking of opening a text file after some calculation. For example, after i press the "calculation", then at the OnCalculation function, it will do some calcuation the it is written to a text file called "result.txt". Then i would like it to open the text file automatically after the calculation instead of i going to the folder to open it to view.
Anyone know how to do so? Thanks
|
by: ecrovoyan |
last post by:
I am trying to write a c++ program that reads through a text file and when i comes across a specific line it adds to that file. i have this code, but it doesnt write "meow" until the end of the text file.. does anyone know how i can get it to write meow on the line after "putwordhere"????????????
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string line;
string searchage;
|
by: Max Steel |
last post by:
Hey gang, I'm new to python coding. I'm trying to find the simplest way to
open a text file (on the same server) and display it's content.
The text file is plain text (no markup language of any kind).
The filename gets found and placed into a variable named
I'm using python to find the text files, and a .ezt template to display the
list of the files. But I can't figure out how to read the contents of the
file, and display it...
|
by: vijendra singh |
last post by:
I have created a notepad in c#.
Now i want to open a text file in my notepad. but i dont know how to do that, can anybody help me?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |