C# :: Using Linq To Get DriveInfo Of ONE Drive

Jul 23, 2014

I want some simple code which will return only the DriveInfo from one drive. I have the below code but it isn't displaying what I expect it to display, I have a feeling i'm using Linq wrong!

var dname = from n in System.IO.DriveInfo.GetDrives() where n.Name == "F" select n.VolumeLabel;
richTextBox2.AppendText(dname.ToString() + "
");

The above should return the devices VolumeLabel which is in port F.

Instead I get the following:

System.Linq.Enumerable+WhereSelectArrayIterator`2[System.IO.DriveInfo,System.String]

View 5 Replies


ADVERTISEMENT

C# :: Linq To SQL With Null Value In WHERE Clause

Apr 13, 2015

I am trying to query fields in a where clause using LINQ to SQL and for some reason I cannot figure out why it doesn't work:

var qryGetMonsterID = (from students in dbContext.tblStudentPersonals
where (students.givenname.Equals(fn)) && (students.familyname.Equals(ln)) && (students.middlename.Equals(mn)) && (students.email.Equals(e))
select students);

The returned SQL Syntax is:

SELECT [t0].[monsterid], [t0].[givenname], [t0].[middlename], [t0].[familyname], [t0].[homeaddress], [t0].[city], [t0].[state], [t0].[postal], [t0].[primaryphone], [t0].[secondaryphone], [t0].[email], [t0].[username], [t0].[lastmodified], [t0].[modifiedby]
FROM [dbo].[tblStudentPersonal] AS [t0]
WHERE ([t0].[givenname] = @p0) AND ([t0].[familyname] = @p1) AND ([t0].[middlename] = @p2) AND ([t0].[email] = @p3)

Not sure but the values for middle name could be null - because not everyone has a middle name and the same is true for e-mail.

View 6 Replies View Related

C# :: Linq To XML - Populate List With Multiple Values?

Aug 26, 2014

I have an XML document, formatted as such:

<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Bookmark Name="1984" Folder="C:UsersmillerDownloads1984 (George Orwell) - Audio Book" Time="00:43:58.4080000" Chapter="0" />
</Books>

Each Element named Bookmark has 4 attributes, Name, Folder, Time, and Chapter.

I'd like to be able to just put all of them in ONE type of container, without making multiple lists... Is there any way, using Linq to XML, to maybe add all of these values to a Tuple?

View 14 Replies View Related

C# :: Join Tables In LINQ With Lambda Expressions

Dec 5, 2014

i have stuck in a join and i cant figure out where the problem is, i have those tables

public class Themes
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }

[Code].....

View 12 Replies View Related

Visual C++ :: LINQ Query To Select Distinct Value From Datatable

Oct 29, 2013

I entered to Visual C++ 2010. Now my intention is to prepare a LINQ Query to select a distinct value from a datatable...

In C# My Query
============
var ProjLnkQry = (from P in MyClass1.ProjTbl.AsEnumerable() select P["proj_name"]).Distinct().ToList();

The above query I try to convert it into VIsual C++

auto DistDepQry=(from v1 in MyGlobalData::ProjectTbl::AsEnumaerable() select v1["depart_name"])->Distinct()->ToList();

But not succeeded.... I found the error like : "from" undeclared Identifier.....

View 2 Replies View Related

C# :: Linq To SQL Query Not Directly Working But SQL Result Text Works

Apr 14, 2015

I am trying to query dates between two textbox values converted to datetime in C#. The dates are returning in the correct datetime and no conversion problem exists there.

However when I run the below LINQ to SQL query in C# it returns no enumerable results. But if I take the below code:

DbCommand dc = dbHistoryContext.GetCommand(qryRes);
Console.WriteLine(dc.CommandText);

and get the results as a string of text and cut and paste that into the SQL Server Management studio and execute it - then it works. What do I need to do to search between two dates so that it properly works. The field is of format Date in SQL Server if that matters and the fields being used to pass the information to it are DateTime. The compiler doesn't show any errors but it just doesn't return results.

var qryRes = (from res in dbHistoryContext.tblR
where res.updateddate >= dtDateFrom.Date && res.updateddate <= dtDateTo.Date
select res);

View 8 Replies View Related

C Sharp :: Linq - How To Group Values Week Wise And Store In Another Datatable

Apr 9, 2013

I have a datatable which comprises values from 1st January to march, something like this:

DataTable datatable = new DataTable("Employee");
datatable.Columns.Add("Date", typeof(string));
datatable.Columns.Add("Employee", typeof(string));
datatable.Columns.Add("Job1", typeof(double));
datatable.Columns.Add("Job2", typeof(double));  
datatable.Rows.Add(new Object[] { "1/4/2013", "A", 1.3, 2 });

[Code] ....

The result should look like this for Job1:

Employee 1/7-1/13 1/14-1/20 1/21-1/27 1/28-2/3 and so on...
A sum of values for this 7 days
B
C
D

I want to add all the values of Job1 for each employee in a time range which is one week starting from monday to sunday. How can I group the Job1 values week wise and store them in another datatable.

View 4 Replies View Related

C++ :: Presence Of A Folder In A Drive?

Dec 15, 2012

using C++ how can i check the presence of a folder in a drive.

The path of the folder is available in a std::string like std::string path = "C:TestFolder";

View 3 Replies View Related

C++ :: Safely Eject USB Drive (In Windows)

May 7, 2014

I would like to be able to safely eject a USB drive (in Windows) when user selects that drive in a listbox and clicks the Eject button in an MFC dialog app. Any functions or (link) that would be up to date (i.e. compatible with Windows 8)?

View 1 Replies View Related

Visual C++ :: Partitioning USB Flash Drive?

Dec 9, 2014

I have written some code to make two partitions in USB flash drive. When I ran it I am not able to make partitions on usb. What'll be the problem in this code.

Code:
/-------------------INITIALIZE AND PARTITION-------------------------------//
#include "stdafx.h"
#include <Windows.h>
#include <stdio.h>

[Code].....

View 3 Replies View Related

C# :: Detecting CD-ROM Drive And Grab Filepath Of Only CSV File

Jul 8, 2014

I would like the user to insert a CD into their computer and click on an button on my application that allows them to read the CD-ROM and find a specific file type, e.g. csv, and then grab the info in the csv file.

I already have my StreamReader setup grabbing a filepath.

Now I am just wondering...how do I detect the CD-ROM and how do I grab the filepath of the only CSV file on the CD-ROM?

What's behind detecting a CD-ROM and grabbing a specific file type from a CD-ROM?

I heard about DriveInfo

However, that only allows me to detect a drive but not look at it's contents.

View 14 Replies View Related

C# :: Saving Excel File In D Drive New Folder?

Jul 17, 2014

I am trying to save the excel file in D:/newfolder. but the file saving as newfolderFilename. The newfolder is already created in D drive. File save path i am getting from textbox ....

View 14 Replies View Related

C/C++ :: Writing To Specific Sector In Flash Drive

Apr 22, 2015

I am trying to write a to a specific sector in a flash drive. The problem is that it will only allow me to write to sectors 0 to 15. When I try sector 16 or higher nothing happens, but in sector 0 to 15 is is working fine.

#define BUFFER_SIZE 512
int main(void) {
FILE *volume;
int k = 0;
long long sector = 0;
char buf[BUFFER_SIZE] = {0};

[Code] .....

View 14 Replies View Related

C/C++ :: Read CSV File From Flash Drive (Ubuntu 12.04)

Mar 26, 2013

I want to read a file from my flash drive called text.csv. However, I cannot even open the port where my flash drive is connected. This is the code that I am using, but I get error since the first part. When I run the program it says "fopen Error". I am using Ubuntu 12.04.

#include<stdio.h>
#include<string.h>  
#define SIZE 1
#define NUMELEM 5  
int main(void) {
    FILE* fd = NULL;

[Code] ....

View 1 Replies View Related

C :: How To Access Sata Hard Drive At Sector Level

Mar 7, 2013

I want to access sata hard drive(eg. D drive) at sector level using C programming.I want to read the values stored in the memory locations.

View 3 Replies View Related

C# :: Mapped Network Drive - Deleting Or Moving A File

Sep 16, 2014

Currently I'm trying to do something extremely basic: delete or move a file

I have a mapped network drive (Y) where I have a file I need to move from one folder to another

First was doing the obvious:

System.IO.File.Move("Y:TempFile.txt", "Y:Temp2File.txt");

Not much to go wrong here, right? As long as I have the correct permission to write in the folders and the folders exists, this would normally go smooth. But for some reason it only copies the file. The source file still exists, but it has successfully copied the file to the destination folder. No exceptions has been thrown or anything... but the file still exists in the source directory

I then changed the code to the following:

System.IO.File.Copy("Y:TempFile.txt", "Y:Temp2File.txt");
System.IO.File.Delete("Y:TempFile.txt");
Console.WriteLine("See mommy, no Exceptions");

As expected the file copies correctly, but the delete command is completely ignored. The file is not deleted, but the Console.WriteLine command is called

I'm running the application as the logged in user. The user has permission to delete the file. If I try from Windows Explorer, the file is correctly deleted. Unfortunately my application refuses to delete the file and even worse, it will not even throw an Exception.

View 10 Replies View Related

Visual C++ :: Get Path To Recycle Bin Folder For Specific Drive?

May 29, 2014

there's a way to get a path to the recycle bin folder for a specific drive for the current user?

Say, on the input one provides "C:" and on the output you get "C:$Recycle.BinS-1-5-18"

View 10 Replies View Related

Visual C++ :: How To Tell If Drive Is BitLocker Encrypted Without Admin Privilege

May 24, 2014

For my purpose all I need to know is drive's BitLocker encryption status by its DOS path. Something like this:

Code:
enum DriveEncryptionStatus{
Unprotected,
Protected,
Unknown
};
DriveEncryptionStatus = GetDriveBitlockerEncryptionStatus(L"C:");

I was able to find the Win32_EncryptableVolume class that unfortunately comes with this caveat:

To use the Win32_EncryptableVolume methods, the following conditions must be met:

You must have administrator privileges.

How to do this without running as an administrator?

View 4 Replies View Related

C Sharp :: Copying A File From Current Directory To System Drive

Feb 8, 2014

I have tried to use File.Copy and File.Move but non of them would work as I expected .....

View 1 Replies View Related

C++ :: Create A Program That Is Able To Save Database Of Items To File On Hard Drive

Mar 18, 2013

Write a program that is able to save a list of items such as books, CDs, or DVDs and the items that are saved must have attributes associated with them. For example a book has a title, author, publisher, and ISBN.I would like to create a program that is able to save the database of items to a file on the hard drive and also retrieve it from the hard drive.I have this for a start of how to set up a storing program.

#include <iostream>
#include <iomanip>
using namespace std;
int main () {
const int arraySize = 10;
int a[arraySize] = { 2, 6, 4, 10, 12, 89, 68, 45, 37 };
int i, hold;

[code]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved