C Sharp :: Cannot Close File With FileStream
Feb 11, 2015
FileStream obj = new FileStream(System.Convert.ToString(row.Cells["Lec_media"].Value),
FileMode.Open, FileAccess.Read, FileShare.Read);
if (Startdate2 == JCM_NOW2) {
if (checkBox1.Checked == true)
[Code] ....
View 1 Replies
ADVERTISEMENT
Apr 9, 2013
I' used to check if my streams are properly opened with a simple:
Code:
if (!file)
std::cout<<"Error message";
However I just realized this is only a valid test if they are initialized with a wrong string and when I tested it:
Code:
int main() {
ifstream f_one("input.txt");
ifstream f_two("not_a_file.txt");
ifstream f_three;
[Code] ....
I didn't get the f_three error message, only the f_two.
how should I check my streams in order to prevent this?
View 6 Replies
View Related
Aug 12, 2014
I wonder, why before accessing a file we need to have it opened, and after finishing with it, we need to close it?
If FileA is already open by PtrA, PtrB won't be able to open it as well until FileA is closed by PtrA?
When PtrA opens a file, are any extra resources allocated by that action?
View 4 Replies
View Related
Dec 22, 2014
Im having a problem with the below code within a console app, I am copying and pasting data across server locations, the copy works fine but it looks like the app wont close and I am left with the screen (Shown in attachment). I want to run this in part of a batch process but because the app stay open it wont move onto the next task.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace SQL_Backup_Move_Files {
[Code] ....
View 3 Replies
View Related
Nov 6, 2012
Consider the following code which closes an overlapped I/O serial handle during application shutdown.
Code:
Win32Com.CancelIo(hPort);
Win32Com.CloseHandle(hPort);
It works fine under .NET 2.0 but after switching to .NET 4.0 it crashes on the CloseHandle. Removing CancelIO doesn't work.
What the correct way is to close an overlapped I/O handle? And why is there the difference between NET2.0 and 4.0?
View 5 Replies
View Related
Feb 9, 2014
Currently I am trying to convert RGB to HSL. Everything is working but the saturation value. It is always close to the correct value (usually less than 10 off). For example:
RGB:(196,72,84)
HSL:(354,-46,52)
Correct HSL(354,51,53)
CODE:
double s=0;
double l=0;
chroma=max-min; //works correctly
//LIGHTNESS
l=(max+min)/2;
//SATURATION
if(chroma==0) {s=0;}
else {s=chroma/(1-fabs(2*l-1));}
s=s*100.000000;
l=(l/255.000000)*100.000000;
View 5 Replies
View Related
Dec 10, 2014
I've been doing some looking and this example seems like the common way to remove the close button on a wpf window. Other than catching the on_click event or using that example, is there no better way to disable/remove that button?
View 2 Replies
View Related
Nov 9, 2012
My 'c' program reads each line of a .txt file, makes a few changes and then outputs the line of text (which are names). I want the contents to be sorted and did not want to bother writing my own sort. The program runs in a command prompt from inside a batch file for example:
sort | makelist.exe BluRay1.txt > sorted.txt
sort | makelist.exe Dvd1.txt >> sorted.txt
..etc..
I have to supply a ctrl-z manually to close the piping. I tried the following which did not work.
buffer[0] = 26;
printf("%c",buffer[0]);
//printf("^(z)");
fclose(stdout);
fclose(stdin);
I never got the above to work so I am avoiding piping and just do a redirect instead.
makelist.exe dvd1.txt > unsorted.txt
makelist.exe dvd2.txt >> unsorted.txt
sort < unsorted.txt > sorted.txt
..etc.
Just wondering if I could have gotten the ctrl-z thru the pipe using "C".
View 2 Replies
View Related
Jun 11, 2013
I wanted to stop the user from having access to USB flash drive while my program is reading data from it.I thought i could do so by closing the explorer at the start of my program and reopening it at the end of it.C Code to close and reopen the explorer?Or how to ban access to the USB flash drive?
View 2 Replies
View Related
Apr 1, 2015
I referred Auto-close message box.
But i like to view the message box with out title bar and buttons. Is it possible?
View 4 Replies
View Related
Jan 11, 2015
i want to create customize close/maximize/minimize button wpf. How can i do that?
View 3 Replies
View Related
Oct 28, 2013
I recently upgraded my operating system from Windows XP to Windows 7 SP1 64 bit. We are using Visual Studio 2008 Professional Edition and Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production.
When I try to execute this code I am getting the below exceptions
HTML Code:
try {
CDatabase *pDatabase = CDatabaseConnection::getDatabaseConnectionProcessLog();
ORSProcessLog rsProcessLog(pDatabase);
[Code] .....
Where rsProcessLog is the CRecordset object using a successfully connected database pointer pDatabase
In 32- bit Debug version I get a message box at rsProcessLog.Close(); with the below text Debug Error
Program: ......Test.exe
HEAP CORRUPTION DETECTED: after Normal block (#506) at 0x0087F628. CRT detected that the application wrote to memory after end of heap buffer.
Memory allocated at f:ddvctoolsvc7libsshipatlmfcsrcmfcdbcore.cpp(2626)
(Please Retry to debug the application)
In 32- bit Release version I get a message box at rsProcessLog.Close(); with the below text Windows has triggered a breakpoint in Test.exe
This may be due to a corruption of the heap, which indicates a bug in Test.exe or any of the DLLS it has loaded.
This may also be due to the user pressing F12 while Test.exe has focus.
The output window may have more diagnostic information.
The above code was a working code in Windows XP with the rest of the env remaining the same and it continues to run in Windows XP but not in Windows 7.
View 9 Replies
View Related
Feb 5, 2014
I need to find a string(&login=) from physical memory dump file.And i have to print the word or string following it.Is there any C# code for this problem?
View 3 Replies
View Related
Dec 11, 2012
I am creating small application using c#.net.I removed all image tag using regular expression no I want to remove all video file and flash file also in source code of webpage.
so far I have tried this ...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
[Code] .....
View 1 Replies
View Related
Aug 25, 2014
This is more of a Application Design question, Let's say I have Form1(Login), this is opened from Program.cs, when the user enters details, the Event Handler makes a instance of a class, adds the data and stores the instance within Program.cs class.
So the best thing to do here, is to close the Form1(Login) and open Form2(Main) via Program.cs so that I can send the List<Login> object with my Login instance objects to said form. This form will remain open throughout the applications use as it's like the main GUI for all the programs functions.
When I close this form, I may want to save some information before the application is terminated, so I may as well store the Login instances in Program.cs anyway.
Main stepping stone: Multiple (usually around 3 max) users can login this system if need be, which will mean closing Form2(Main) and then opening Form1(Login) so that once Form1 is closed it can recreate the From2(Main) form and pass the new List<Login> to that form.
What's the best way to do this, at the moment i'm creating the Form2 instance like so:
//....
//Detect the Login form being closed
loginForm.Closed += new EventHandler(OnLoginClosed);
//...
//Open the main form when the login is closed
private void OnLoginClosed(object sender, EventArgs e)
[Code] .....
This seems like it will work and do the job, but is there a better and cleaner way? The List<Login> will be passed to Forms which are created via Form2(Main) as this information will be needed. It's just that ive been told not to use Forms for too much data containment.
View 2 Replies
View Related
Nov 4, 2014
I was opened CPropertySheet from main dialog at very first time, again i was opened the CPropertySheet from current PropertySheet's Page 1 using button click event.
How can i close these two sheets and go to main dialog.
I was used EndDialog(0);
Which goes to previous sheet only.
View 4 Replies
View Related
Dec 8, 2012
Simply put, i created a .ico file and i want to use it as the NotifyIcon icon. But i can not for the life of me figure it out..
View 2 Replies
View Related
Jan 23, 2013
I am making an application that runs on Machine1 and the purpose of the application is to copy the files from Machine1 to Machine2. It works fine but i have to share the folder of the Machine2 where i copy the files.
Is it possible without sharing.
View 1 Replies
View Related
May 15, 2013
I have a table in my database that has a 3 fields.
RuleID | RuleName | Rule
the ruleID is a randomly generated string of characters, RuleName is the name the user gives to the rule, and the Rule field is about 600 characters long and is just XML text.
I want to read that Rule field from the database and use it inside the function below.
private static List<MenuItem> LoadRules(bool evaluationType)
{
//string path = HttpContext.Current.Server.MapPath(string.Format("/Rules/{0}/{1}/", ip, evaluationType ? "Evaluation" : "Execution"));
[Code]...
This function loads an xml file from a static location and parses out some information to a context menu.
BUt i'm culeless on how to have the function read the xml info found inside my database.
View 1 Replies
View Related
Dec 28, 2013
I am currently having issues with the following code when trying to create a excel file using C#. This is the code that I have at the moment.
oXL = new Microsoft.Office.Interop.Excel.Application();
oXL.Visible = false;
oWK = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(System.Reflection.Missing.Value));
oWK.SaveAs(path + "" + fileName);
oWS = (Microsoft.Office.Interop.Excel._Worksheet)oWK.Worksheets.get_Item(1);
oWS.Cells[1, 1] = "Student ID";
oWS.Cells[1, 2] = "Student Name";
oWK.Save();
The line that I am having issues with is
oWS = (Microsoft.Office.Interop.Excel._Worksheet)oWK.Worksheets.get_Item(1);
If I remove it, I am able to create and save teh workbook in the directory. However, I want to make some changes on a worksheet, and that is where the issue is. I have also tried using the line of code:
oWS = (Microsoft.Office.Interop.Excel._Worksheet)oWK.Worksheets[1];
This line had no luck either. The issue I am having is the error regarding InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain.
View 2 Replies
View Related
Oct 16, 2013
So I have this program which read single text file and write in other. Basically read every line then write to another file "this number is n times here + numbers".
How to modify this to store only 1 time the number in second file. What I mean is not like now:
Now output is:
Count of matching numbers in this group: 7
Numbers:
01070400
01070400
01070400
01070400
01070400
01070400
01070400
Is better to be:
Count of matching numbers in this group: 7
Number:
01070400
Code that I use is:
string path = "text.txt";
var result = (File.ReadLines(path)).OrderBy(x => x).GroupBy(x => x);
using (var writer = new StreamWriter("test1.txt")) {
foreach (var item in result) {
string outGrp = String.Format("Count of matching numbers in this group: {0}", item.Count());
[Code] ...
View 1 Replies
View Related
Apr 24, 2013
The code below is used to return a file path.
private string BrowseJournalFile(string startRelativePath)
{
string str = "Journal files (*.log)|*.log|All files (*.*)|*.*";
return PathTools.BrowseFile(startRelativePath, str, this.RootPath);
}
So once I click browse I get something like "E:New Files" But there is this .log file in this folder which I want to automatically store in this path.
Right now I have to click on this .log file and then select open. Is there a way I can directly load the file.I have been trying to use the FileStream but no luck.
View 7 Replies
View Related
Oct 21, 2012
How can I calculate the total of pages for all file(pdf,word,excel,txt...) types in a directory with c#?
View 2 Replies
View Related
Aug 3, 2013
I am developing a win form application with sq l server2005, in client system after install the application I created the folder for storing the database of running application, like that I have every year database separately, My doubt is how to connect the particular year database while loading the app?
View 1 Replies
View Related
Feb 19, 2013
E.g. i have a log file in which there are many entries for appGUID. Now how many appGUID's are there, for this i have a code, but how many of them are unique, for this i don't have code.
View 4 Replies
View Related
Apr 16, 2013
how to do this in C#. Need to connect to Oracle db, take a file from directory then read every line of the file. Lines are like this:
123234847656|8800359898818177|A|20130401 14:51:42|
123234847212||D|20130401 14:52:08|
123234847212||M|20130401 14:55:38|
Then will split as string on every '|' char and according to this flag |A|, |D| or |M| I will add/delete/modify information inside. I have trouble with this part with the connection and read/split file and check for the flag A, D or M.
View 2 Replies
View Related