I am using SharpSVN to connect and retrieve information from Visual SVN Server by C#.
But on SVN Server, a Repository have folder with the name is C# and when read to this folder, exception occurred:
Additional information: URL
'https://< svnserver >/svn/IT/02_SHOPFLOOR/C' non-existent in
revision 13
I debug and found that URI still be:
{https://< svnserver >/svn/IT/02_SHOPFLOOR/C#} System.Uri
How could I do to access SVN repositories which contain special characters?
I had used like following but nothing changed:
if (lists[i].Path.Contains("#"))
{
path = lists[i].Path.Replace("#", "\\#");
}
else
{
path = lists[i].Path;
}
reposss[i] = new Uri("https://< svnserver >/svn/IT/02_SHOPFLOOR/" + path);
svnClient.GetList(reposss[i], out listsInfo); //Exception occur at here
The # is the schema operator in a Url. You need to escape this character using the uri escape rules. There are helper functions for this on the System.Uri class and for some specific scenarios on SvnTools. The escaped character will be something like %23 where 23 is the hexadecimal value of the character.
Related
I am looking into trying to compare 2 URLs in C# for equal root domains, I.E.
sub.example.com matches example.com and othersub.example.com.
I had a look into using the Uri class, but that will parse the full URL including the subdomains.
I had thought about splitting the string at each . and then comparing the last 2 last elements which would normally be the root domain name, however that causes issues as often the TLD can also have a subdomain I.E. example.com.au would then match other.com.au.
I guess I'm hoping if anyone knows a NuGet library that can take into account common top level domains (including multi part ones) and then compare the actual specified domain
You can use Nager.PublicSuffix package.
Install via nuget:
PM> Install-Package Nager.PublicSuffix
Example:
var domainParser = new DomainParser(new WebTldRuleProvider());
var domainInfo = domainParser.Parse("sub.test.co.uk");
//domainInfo.Domain = "test";
//domainInfo.Hostname = "sub.test.co.uk";
//domainInfo.RegistrableDomain = "test.co.uk";
//domainInfo.SubDomain = "sub";
//domainInfo.TLD = "co.uk";
Then compare via the domainInfo.TLD
Adding triplets to GraphDB
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://localhost:7200/sparql"), "http://localhost:7200/");
SparqlResultSet results = endpoint.QueryWithResultSet("PREFIX : <http://www.example.org/> INSERT DATA {:test :test :hhrh }");
why does not it work?
StardogConnector stardog = new StardogConnector("http://localhost:7200", "test", "admin", "posw");
stardog.Begin();
string query = "PREFIX : <http://www.example.org/>SELECT * WHERE {:" + line[0] + " ?k :" + line[1] + "}";
stardog.Query(query);
stardog.Commit();
another way, same problem. Created a DB on a lokalka
Yes, I also came to this conclusion, I use GraphDB for the first time. Well, how can I implement it with a file? I wrote such code.
IGraph g = new Graph();
string sql = "PREFIX : <http://www.example.org/> INSERT DATA {:test :test :hhrh }";
g.LoadFromFile("t.n3");
Object results = g.ExecuteQuery(sql);
here comes such an error
VDS.RDF.Parsing.RdfParseException
HResult = 0x80131500
Message = [InsertKeywordToken at Line 1 Column 36 to Line 1 Column 42] Unexpected Token encountered - expected a BASE / PREFIX directive or a Query Keyword to start a Query
Source = dotNetRDF
Stack trace:
in VDS.RDF.Parsing.SparqlQueryParser.ParseInternal (SparqlQueryParserContext context)
in VDS.RDF.Parsing.SparqlQueryParser.ParseInternal (TextReader input)
in VDS.RDF.Parsing.SparqlQueryParser.ParseFromString (String queryString)
in VDS.RDF.GraphExtensions.ExecuteQuery (IGraph g, String sparqlQuery)
in algorAutoText.Program.Main (String [] args) in C: \ Users \ Denis \ source \ repos \ algorAutoText \ algorAutoText \ Program.cs: line 43
judging by mistake, I supposedly did not add BASE / PREFIX. But he is in the request
Update and delete queries come through the /statements endpoint,
i.e. /repositories/{repository_id}/statements.
You can see the RDF4J server REST API here:
http://docs.rdf4j.org/rest-api/#_the_rdf4j_server_rest_api
When you use the DELETE or INSERT keywords you are doing a SPARQL Update, not a Query. SPARQL separates Query and Update into two separate specifications and most triple stores implement them as two separate endpoints (e.g. for security reasons).
To do an update from dotNetRDF into a triple store you have two options.
You can work directly with the SPARQL update endpoint in which case you will need to check the documentation for your triple store to find out how to create the URL for that - see https://github.com/dotnetrdf/dotnetrdf/wiki/UserGuide-Updating-With-SPARQL#remote-updates for details.
Alternatively if your triple store is one of the ones supported by dotNetRDF (Stardog and Sesame/GraphDB both are), then there are convenience wrappers that make this a bit easier - for more information about this please refer to https://github.com/dotnetrdf/dotnetrdf/wiki/UserGuide-Triple-Store-Integration#update
I am completely stumped on this one, I have a static class attempting to detect if a directory exists, but for some reason, it throws the following error:
Program.Main encountered an error: Object reference not set to an instance of an object. Stack trace: at csv.prepareCSVData() in path/csv.cs:line 21
at RLCSVTools.Program.Main(String[] args) in path\Program.cs:line 31
This is the code that produces that error in csv.cs.prepareCSVData:
ConfigurationSync.logDebugMessage(logMessageType.warning, "CSV class Dir: " + exportPath);
//this log works and reveals exportPath has been populated
if (Directory.Exists(exportPath) == false)
//breaks here regardless of dir existing or not
{
ConfigurationSync.logDebugMessage(logMessageType.warning, "Recreating the directory: " + exportPath);
// I have never seen this log run
Directory.CreateDirectory(exportPath);
}
I have added some comments in the code to show at exactly what line the error occurs.
All members of this class, including the class, are static. public static class csv
Has anyone experienced anything like this? I can't seem to find a solution.
So lets look at the documentation
Directory.Exists(String) Method
Doesn't throw any exception
CreateDirectory(String)
Creates all directories and subdirectories in the specified path
unless they already exist.
Exceptions
IOException
The directory specified by path is a file.
-or-
The network name is not known.
UnauthorizedAccessException
The caller does not have the required permission.
ArgumentException
path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid
characters by using the GetInvalidPathChars() method.
-or-
path is prefixed with, or contains, only a colon character (:).
ArgumentNullException
path is null.
PathTooLongException
The specified path, file name, or both exceed the system-defined maximum length.
DirectoryNotFoundException
The specified path is invalid (for example, it is on an unmapped drive).
NotSupportedException
path contains a colon character (:) that is not part of a drive label ("C:\").
Its clear that CreateDirectory(String) is not your problem
So by deducation the only obvious issue here is exportPath is null
For which this is relevant
What is a NullReferenceException, and how do I fix it?
if exportPath is not null, then you need to debug your application, something is not what it seems
I'm doing database unit testing and I'm trying to write data to files via localhost, but I'm getting the error Exception occurred: The network name cannot be found. I have a byte array that I want to put in a text file like so:
File.WriteAllBytes(outputFilePath, res);
Where res is the byte array and outputFilePath is a string assigned as "\\localhost\InterfaceFiles\Requirements.txt".
All the documentation I can find on the data types and operators indicate this should work. Anyone have an idea why it isn't? The file Requirements.txt doesn't exist yet, but WriteAllBytes should create it in that case.
edit: unchecked "trustworthy" in the Visual Studio database settings.
Try replacing localhost with your actual PC name; the computer host name which you get by running hostname command under command prompt.
"\\PC_NAME\InterfaceFiles\Requirements.txt"
Check the string assignment, I mean the string literal. If it contains single backslashes, then it should preceded by #. If no # then all backslashes should be doubled like:
#"\\host\path\filename.any"
// or
"\\\\host\\path\\filename.any"
I first had this SQLite version: 1.0.77.0 (sqlite-netFx40-static-binary-bundle-Win32-2010-1.0.77.0)
and everything was working fine.
After updating my System.Data.SQLite.dll to version 1.0.82.0 (sqlite-netFx40-static-binary-bundle-Win32-2010-1.0.82.0) I now receive this:
Unable to open database. Connection string: 'datetimeformat=ISO8601;synchronous=Off;uri="file://C:/Users/username/Documents/data/test.db";version=3;journal mode=Truncate;default isolationlevel=ReadCommitted;pooling=True'; Error: 'System.InvalidOperationException: Invalid connection string: invalid URI
I've also tried file:/// instead of file:// without any luck.
Could anybody tell me what is wrong with my URI, why it doesn't work anymore in v1.0.82.0 but worked in v1.0.77.0?
http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
(1.0.82.0 == 3.7.14)
The best way to get correct connection string is to always use the SQLiteConnectionStringBuilder class to generate them.
SQLiteConnectionStringBuilder conn_builder = new SQLiteConnectionStringBuilder
{
DateTimeFormat = SQLiteDateFormats.ISO8601,
SyncMode = SynchronizationModes.Off,
Version = 3,
JournalMode = SQLiteJournalModeEnum.Truncate,
DefaultIsolationLevel = System.Data.IsolationLevel.ReadCommitted,
Pooling = true,
Uri = new Uri(#"c:\tmp\db.sqlite").AbsoluteUri
};
string conn_str = conn_builder.ConnectionString;
if Uri is not working, try setting DataSource instead (if you are using a local file).
A quick check shows that DataSource is evaluated before Uri in SQLiteConnection.cs and takes precedence over it, so if there is a bug in the Uri handling, using DataSource may help bypassing it.
According to the docs starting from the version 1.0.82.0 it was changed:
Add support for URI file names via the new FullUri connection string
property.
Example:
var connection = new SQLiteConnection("FullUri=file:mydb.sqlite?cache=shared");
following works for me, for following example you can't not use Data Source
FullUri=file::memory:?cache=shared
See these URI filename examples, but your URI (with three slashes) looks correct.
I think you should try to strip down your connection string to the basics and then add the options.
Take a look at this site for example SQLite connection string options.
http://www.connectionstrings.com/sqlite
The 3 /// is only valid when you are trying to escape out the spaces in the uri, I would also say that you should try moving the db out of the users folder to the root on c:\ in case the access permissions are not valid for it to access the DB and it also means a simpler connection string for you to try.
Good luck